Step-by-Step WCF (4): use proxy services on the client

Source: Internet
Author: User

First, the client must know the service contract before using the service on the server. The server publishes its own contract, and the client generates a proxy class based on the contract.

1. Open the previous solution

2. Configure the service behavior to allow the client to discover the contract and how to discover the contract.

The description of the yellow annotation can be found through HTTP. Here is http: // localhost: 9000

Green is the address of another discovery contract we added. It can be found through HTTP. Of course, it can also be configured as another protocol. Here is http: // localhost: 9000/MEX.

3. Generate the client proxy class in two ways. One is to add service refrencethrough IDE, and the other is to use svcutil.exe of msbench.

(1). Use ide

Step 1: Right-click Add service reference

Step 2: Enter the address of the server metadata

Step 3: OK

Step 4: modify program. CS as follows:

(2)use svcutil.exe to generate the proxy class, enter the following Red Command, and then add the generated file to the project. Others are the same as above. The benefit of svcutil is that many switch options are provided.

Noconfig does not generate a configuration file, so we need to modify the configuration file by ourselves. here we can use the configuration file in the previous section.

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: 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.