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.