Invoke a remote WCF service using. NET 2.0, which calls the WCF service as a Web service service. However, because of WCF encapsulation issues, especially for WCF posted to remote servers, there are a number of problems with client invocation.
Here are three ways to illustrate this problem: WCF server, generate client proxy file, problems that arise, WCF service side
Because the 2.0 call WCF service is used, the binding is configured as BasicHttpBinding, even with a simple HTTP protocol for service invocation. 1, configuration file:
Configure WCF to be the appropriate binding, regardless of address problem before release
<system.serviceModel> <services> <service behaviorconfiguration= "NWS. Wcfservice.service1behavior "Name=" NWS. Wcfservice.nwsservice ">
2, the program business logic:
Here omitted, can imagine a business requirement, if a download profile needs, method name is Downloadconfig () 3, test local WCF service:
Use the WcfTestClient tool.
vs Command Prompt tool (more than 2008), enter:
The WCF Client Test tool pops up
Using the VS-band test tool, you will be able to quickly and efficiently complete the testing of WCF services.
second, the generation of proxy class 1. wsdl generation
Open the Visual Studio 2008 Command Prompt tool and navigate to the path to the placement proxy class file, which is used in the example D disk.
Enter the following command:
WSDL http://localhost:5678/networkspeedservice.svc?wsdl
The system prompts you to write to the file, as shown below.
In fact, the proxy class generated by this method will request WCF services with the WebService SOAP protocol, so the only protocol that WCF can use is the basic mode. But this is a useful approach in the development of. NET 2.0 applications.
2. svcutil Generate WCF client proxy class and configuration file
In addition to accessing WCF services using basic WSDL,. NET 3.0 applications can generate WCF client invocation proxies using svcutil commands and generate a configuration file.
The WCF service can be invoked by incorporating the generated proxy class into the project.
iii. problems that arise
Well, because the draft has been on for years, forget what's wrong here. Wait till you get up.