A Preliminary Study of WCF-7: Use of WCF Service Configuration tool, wcf-7

Source: Internet
Author: User

A Preliminary Study of WCF-7: Use of WCF Service Configuration tool, wcf-7

In the previous WCF Service configuration, the article explains the basic node and attribute structures required for the WCF configuration. However, when writing a program for beginners, the location and attributes of these nodes are often not very clear, so we cannot run the service program because of configuration file errors. Visual studio provides a Visual Configuration interface (Microsoft Service Configuration Editor) for Service Configuration, which greatly facilitates Service Configuration by developers. The following shows how to configure a WCF Service Program:

1. Create a solution WcfConfigTool, add a Service program of the class library type and a Host Program of the console application, as shown in the code of each file:

  

  

  

2. Use the Microsoft Service Configuration Editor to configure the Service program. Select the WCF Service Configuration Editor under the tools option in the visual studio menu and click it.

  

3. After opening the editor, select File> new configuration. On the configuration page, we can configure the service.

  

  

  

  

  

  

  

  

4. Configure the service base address, click the host option in the left service menu item, and then click Create in the lower right corner to add the base address.

  

  

5. Change the binding type of the default endpoint to wsHttpBinding, and set the DNS in the identifier to Localhost.

  

  

6. Add the metadata endpoint configuration, select the left-side endpoint menu option, and right-click to create a service endpoint. Set Address to mex, Binding to mexHttpBinding, and Contract to IMetadataExchange.

  

7. Add binding configuration, select the binding menu on the left, and create binding Configuration

  

  

  

8. Configure the endpoint behavior, select the endpoint behavior configuration of the advanced options on the left to create the endpoint behavior configuration, set the name to endpointBehavior, and click Add to add the endpoint Behavior

  

  

  

9. Add the service behavior configuration, and select the service behavior menu item on the left to create the service behavior configuration. Set the name to serviceBehavior and click Add and add service behavior.

  

  

  

  

  

10. Select BehaviorConfiguration for the service as serviceBehavior. Click Service. Service1 on the left and set BehaviorConfiguration on the Right To serviceBehavior.

  

11. Select binding configuration and behavior configuration for the endpoint, click the first endpoint on the left, and set BehaviorConfiguration on the Right To endpointBehavior and BindingConfiguration on binding1.

  

12. click the Save As option under the File menu to save the file and copy the configuration file content to the App under the previously created Host project. in the config file, after compiling the program, you can run the host service. At this point, we have completed a service program configuration task.

  

13. You can use the WCF client to verify whether the service has been successfully published. The command in visual studio Tools in the Start Menu prompts the Visual Studio command prompt (2010). Enter the wcftestclient command to open the WCF test client.

  

  

 

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.