C # Use the WSDL tool provided by VS to generate the WebService class,

Source: Internet
Author: User

C # Use the WSDL tool provided by VS to generate the WebService class,

There are two ways to use WebService: one is to add service reference directly, and the other is to generate through WSDL. You have used it to add service references. I will not explain it here. So, since there is a direct reference method, why do we need to generate it through WSDL? Because only one. cs file is generated through WSDL, which is easy to manage and more concise.

 

1. generation steps

1. Open the vs development console, such:

 

2. Enter the following command in the console:

Wsdl/language: c #/n: Demo/out: d:/TestService. cs http://www.abc.com/webservice/test? Wsdl

Parameters are described as follows:

/Language: C # specify the programming language as C #

/N: Demo specifies the namespace as Demo

/Out: Specify the file storage path and file name d:/TestService. cs

Http://www.abc.com/webservice/test? The wsdl file path can also be a physical path (for example, C:/test. wsdl)

 

3. After the command is input, press Enter. The execution is successful, as shown in figure. Then, you can find a generated file named TestService. cs from drive F.

 

 

Configure wsdl.exe in the vs tool menu.

Every time you open the vs development console and enter a long string of commands, it will be troublesome. To improve the efficiency, we will configure it in the tool menu to make it easier to use.

 

Configuration steps:

1. Choose vs> Tools> external tools.

2. Click Add. The detailed configuration is shown in figure

 

Note:

A. The command is written in the path C: \ Program Files (x86) \ Microsoft SDKs \ Windows \ v10.0A \ bin \ NETFX 4.6.1 Tools \ wsdl.exe of the wsdl.exe Program on the computer.

B. The parameters are the same as described above.

C. For the initial directory, select [item Directory]. When you select a folder in the solution, the generated class file will be saved in the folder you selected. If you select a file, the generated class file is saved in the same directory as the selected file.

 

3. Click the application button to complete the configuration.

 

How can I use it after configuration? After configuration, click the tool menu and you will see the following:

 

Click the WEBSERVICE generation tool, as shown in figure

 

Change "namespace" to the namespace you actually want. I will write Test here, and then enter a space after/out: (remember to enter a space ), enter the path of the wsdl file (either the physical path or the network path ). As shown in figure

 

Click OK. The details are displayed in the output window at the bottom of.

 

Related Article

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.