IIS releases WCF (supplement the content on the Internet with the source file)

Source: Internet
Author: User
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

Related Article

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.