How ASP. NET Call Web Service

Source: Internet
Author: User

Invoking a Web service in. NET is as simple as creating a Web service.

The implementation steps are as follows.

(1) First we create an ASP. NET WEB application.

(2) Add a Web Service reference.

Right-click on the item and choose the Add Web Reference command from the shortcut menu that pops up.

    

Add references in the following 3 scenarios.

1. If the Web service is in this solution, select the first one, and the program will automatically turn to the service address in the solution.

2, if the Web services on this computer, the system will automatically find the local Web services for you to choose.

3, in either case, the ultimate goal is to enter the appropriate address at the URL, loading, so we can enter the URL of the Web service address, whether local or public network is the same. Then, clicking the Go button lists the test page and method description for the Web service, and verifies that the project is able to use the Web service, as shown in.

    

In this case, we enter a name in the Web reference name text box, and we will use that name in the code to programmatically access the selected Web service and click the Add Reference button.

(3) At this point, the project is more than a directory called Web References, 7-9, the auto-generated proxy class is placed here.

  

(4) Click the "Show All Files" button in Solution Explorer in the project, then you can see the proxy class, called Reference.cs.

(5) Using this proxy class in code is basically the same as using a local normal class.

Productservice.ltpservice service = new Productservice.ltpservice ();

String Price=service. GetProductPrice ("001");

To this end, the process for ASP. NET calls to the Web Service is complete, with only two lines of code written throughout the process.

How ASP. NET Call Web 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.