Writing and invoking a simple WCF service

Source: Internet
Author: User

1: This simple WCF demo consists of 3 files: an interface (which defines the method provided by the service), 1 entity classes, and one. Svc file (method implementation process)

2. After writing the code for the Service, edit the WCF configuration file, if shown:

3. Write the configuration information in the endpoint and bindings of the client and save it.

4. Press F5 to run, the WCF test client will be invoked. If the service and configuration you are writing are normal, the client interface is:

Using this tool, you can test the data returned by methods in the interface, and a simple WCF service program is ready to write. The next step is to publish the WCF service to IIS

5. Right-click the solution and publish the WCF service to a folder

6. Add the folders generated after publishing to IIS, click Browse, and you can see that the WCF service published successfully in IIS

7, using the SvcUtil.exe tool, get the client file and configuration file of the service,

8. Copy the contents of <system.serviceModel> in client files and configuration files into Web. config, such as:

9. A reference to the WCF service has been completed, and the methods provided in the WCF service can be used in code.

Note: 1. Be sure to edit the WCF configuration file after you write the WCF service, otherwise you will not find an endpoint error when referencing in another program

2. Using SvcUtil.exe to generate client code and configuration files

3, after the completion of the WCF service, first press F5, with the WCF test client to determine whether the service is correct, this step is not through the other next is wasted

Writing and invoking a simple WCF service

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.