Use IIS as the host to publish your WCF Service

Source: Internet
Author: User
A recent company requirement involves WCF development. I found some information on the Internet, mostly using a separate application or Windows service as the host of the WCF Service. In fact, WCF also provides a way to publish your WCF Service Based on IIS, which is similar to remoting in the past.

The general deployment steps are as follows:

1. Compile the class library of the WCF Service to ensure there are no errors.
2. Create a. SVC file in the following format: 1 <% @ servicehost Language = C # DEBUG = "true" service = "commonservice. mailservice" %>


The service here is your service name and its namespace.

To ensure that IIS can correctly identify the. SVC file, you must check the IIS properties. If there is no. SVC type, you must manually add it,

3. Publish the WCF Service in IIS and set its directory to Web Sharing. Note that the anonymous access permission is enabled for this virtual directory in IIS.
4. Add the Web. config file to the project. Here we need to establish the configuration information of the WCF Service segment. We can directly use the configuration tool provided by MS for convenient configuration,

Open the configuration tool and select the service type and contract information according to the Configuration Wizard. When selecting the service communication mode, we need to select the HTTP Communication Mode (because the service host is IIS, we should select the http mode ). In endpoint, enter the endpoint address. Then, add an endpoint, with the address as MEX, the type as Mexico httpbinding, and the contract value as imetadataexchange.

5. In order to test the publishing effect in IIS, we need to allow the client to obtain metadata through HTTP. The default value of WCF is false, so we need to make a small setting:
On the service behavior node, right-click a service behavior and click Add to add an extention position named servicemetadata,

Double-click it. In the window, set httpgetenabled to true,

After everything is ready, we can access and test our WCF Service through IIS. For example:

The section in the red box shows the result of setting httpgetenabled. Otherwise, this line does not appear. It allows us to obtain its source data from the client in the WSDL mode.
Summary: When IIS is used as the host program, you do not have to create a host file for the WCF Service.

Posted on cooldog's. Net Space reading (1267) Comments (7) EDIT favorites

Feedback # 1st floor | James

Can you give a source file? security settings for this service require 'anonus us' authentication but it is not enabled for the IIS application that hosts this service will appear during IIS debugging.
Error
Reply to reference for details #2 floor [main poster] | cooldog's. Net Space

In your IIS virtual directory attribute, you need to check the option of allowing anonymous access.
View reply reference #219.155.82. * | zjysky [unregistered user]

Which file is added for program extension. I can't see it.
Reply to reference #4 floor [main poster] | cooldog's. Net Space

@ Zjysky:

Open IIS and right-click the website ---> Properties
Select the "main directory" tab, click "configuration", and add in "ing.
Reply to reference for details #58.53.121.*2008-01-23 | lizhiyong [unregistered user]

What can I do if I don't understand it !!!!!
Ah ~~~~~
Reply to reference # 6th floor 219.135.147.*2008-05-08 | shirlly [unregistered user]

Which DLL is the executable file added in the second part?
Reply to reference #7 floor [] | cooldog's. Net Space

@ Shirlly:
C: \ windows \ Microsoft. NET \ framework \ v2.0.50727 \ aspnet_isapi.dll

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.