Http://blog.csdn.net/blacksource/article/details/3942130
A recent company requirement involves WCF development. I found some information on the Internet, mostly using separate applications.ProgramOr 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.