C # generates WebService service classes using the VS-own WSDL tool

Source: Internet
Author: User
Tags wsdl

There are two ways to use WebService, one is to add a service reference directly, and the other is to generate it through WSDL. Add a service reference everyone has used it, here is not explained. So, since there is a direct reference to the way, why should it be generated by WSDL? Because it is generated through WSDL, there is only one. cs file that is easy to manage and more concise.

First, the Build step

1. Open the VS development console, such as:

2. Enter the following command in the console

wsdl/language:c#/n:demo/out:d:/testservice.cs http://www.abc.com/webservice/test?wsdl

The parameters are described below

/language:c# specifies that the programming language is C #

/n:demo specifying the namespace as Demo

/out: Specifies the file save path and filename D:/testservice.cs

HTTP://WWW.ABC.COM/WEBSERVICE/TEST?WSDL is a WSDL file path, or it can be a physical path (for example: C:/TEST.WSDL)

3. After the instruction input is completed, press ENTER to execute the success as shown, the F disk will be able to find a generated TestService.cs class file.

Second, configure the Wsdl.exe in the VS Tools menu

Because each time you open the VS development console and enter a long list of instructions it can be cumbersome, so to improve efficiency, we configure it in the Tools menu to make it easier to use.

Configuration steps:

1. Open Tools menu-Tools

2. Click Add, detailed configuration such as

Description

A. The command fills in the path of the Wsdl.exe program in the computer C:\Program Files (x86) \microsoft Sdks\windows\v10.0a\bin\netfx 4.6.1 Tools\wsdl.exe

B. Parameters and the above-mentioned agreement, no longer repeat

C. initial directory, select [item directory]. The role of the project is that when you select a folder in the solution, the generated class file is saved in the folder you selected, and if the file is selected, the generated class file is persisted and the selected file sibling.

3. Click the Apply button to complete the configuration.

How do you want to use it after configuration? When you're done configuring, click on the Tools menu and you'll see such as:

Click the WebService Build tool, which appears as

We replace the "namespace" with the name space that we really want, I write test here, and then in the/out: After a space (remember must be a space), then fill in the WSDL file path (can be a physical path or network path). Upon completion as

Click OK and you can see the details in the Output window at the bottom of vs.

C # generates WebService service classes using the VS-own WSDL tool

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.