How to create and use a Web Service proxy class

Source: Internet
Author: User
Tags wsdl
How to create and use a Web Service proxy class

Web service proxy supports. net programming language files, which are automatically generated by the WSDL tool provided by the. net Framework. The proxy class does not contain any application logic. Instead, it contains the transmission logic about how to pass parameters and search results, and a list of methods and prototypes in the Web service. The proxy class can be created from any WSDL file.

You can access the Web service just like accessing a com object. To access the Web service, you must create a proxy class from the Web service's WSDL document on the local computer .. Netmask the tool named wsdl.exe to automatically generate a Proxy file. The creation and use processes are described as follows:

1. Create an asp Application (# C) project named TeachShow. Create a folder named Charpter8 in the TeachShow project and create a new Web service under the folder named: computer. asmx
2. Switch to the code View and write the following code:
[WebMethod (Description = "used for addition", EnableSession = false)]
Public int Add (int a, int B)
{
Return a + B;
}

[WebMethod (Description = "used for subtraction", EnableSession = false)]
Public int Sub (int a, int B)
{
Return a + B;
}

[WebMethod (Description = "used for multiplication", EnableSession = false)]
Public int Multi (int a, int B)
{
Return a * B;
}

[WebMethod (Description = "used for division operations", EnableSession = false)]
Public double Devide (int a, int B)
{
Return Convert. ToDouble (a)/Convert. ToDouble (B );

3. Compile the entire project by pressing F5 (this step must be done, and cannot be implemented without step 1)

4. Open the MS.net 2003 command prompt tool and enter: C:> wsdl http: // localhost/TeachShow/Charpter8/FirstAndUse/Computer. asmx/n: ComputerNameSpace. ComputerNameSpace is a custom namespace. The prompt is as follows:

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.