Invoking a remote WCF service using. NET 2.0 __.net

Source: Internet
Author: User
Tags wsdl

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.




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.