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.
The above is the content transferred from the Internet. After testing, I don't know whether the Internet users appear:Security settings for this service require 'anonymous' authentication but it is not enabled for the IIS application that hosts this service.
If yes, see the following supplementary content:
The above reason is that we have not set direct authentication, so we need to add a section in the configuration file web. configCode:
<System. Web>
<Authentication mode = "Windows"/>
</System. Web>
This problem has been solved...
The source file I wrote is attached, which can be released and debugged in IIS.
:Wcf.rar