Compartilhar via


Web Services Description Language Tool (Wsdl.exe)

This topic is specific to a legacy technology. XML Web services and XML Web service clients should now be created using Windows Communication Foundation.

The Web Services Description Language tool generates code for XML Web services and XML Web service clients from WSDL contract files, XSD schemas, and .discomap discovery documents.

Note

WSDL.exe may generate classes with names like “@string”. These are valid type names using the ‘@’ prefix to allow type names that consist of a C# keyword.

wsdl [options] {URL | path}

Remarks

Argument Description

URL

The URL to a WSDL contract file (.wsdl), XSD schema file (.xsd), or discovery document (.disco). Note that you cannot specify a URL to a .discomap discovery document.

Path

The path to a local WSDL contract file (.wsdl), XSD schema file (.xsd), or discovery document (.disco or .discomap).

Note

Wsdl.exe does not retrieve includes and imports from the network when it is given a local file. To enable Wsdl.exe to retrieve network resources while processing a local file, pass a URL to the local file. For example, the following file uses the network to retrieve necessary resources: wsdl File:///E:/Customers/WSDLS/Accounts.wsdl /out:proxy.cs

Option Description

/appsettingurlkey:key

or

/urlkey:key

Specifies the configuration key to use to read the default value for the URL property when generating code. When using the /parameters option, this value is the <appSettingUrlKey> element and contains a string.

/appsettingbaseurl:baseurl

or

/baseurl:baseurl

Specifies the base URL to use when calculating the URL fragment. The tool calculates the URL fragment by converting the relative URL from the baseurl argument to the URL in the WSDL document. You must specify the /appsettingurlkey option with this option. When using the /parameters option, this value is the <appSettingBaseUrl> element and contains a string.

/d[omain]:domain

Specifies the domain name to use when connecting to a server that requires authentication. When using the /parameters option, this value is the <domain> element and contains a string.

/l[anguage]:language

Specifies the language to use for the generated proxy class. You can specify CS (C#; default), VB (Visual Basic), JS (JScript) or VJS (Visual J#) as the language argument. You can also specify the fully-qualified name of a class that implements the System.CodeDom.Compiler.CodeDomProvider Class. When using the /parameters option, this value is the <language> element and contains a string.

/n[amespace]:namespace

Specifies the namespace for the generated proxy or template. The default namespace is the global namespace. When using the /parameters option, this value is the <namespace> element and contains a string. This element must be in the parameters file.

/nologo

Suppresses the Microsoft startup banner display. When using the /parameters option, this value is the <nologo> element and contains either true or false.

/order

Generates explicit order identifiers on particle members.

/o[ut]:filename or directoryname

Specifies the file (or directory) in which to save the generated proxy code. You can also specify a directory in which to create this file. The tool derives the default file name from the XML Web service name. The tool saves generated datasets in different files. When using the /parameters option, this value is the <out> element and contains a string.

/parameters

Reads command-line options from the specified XML file. Use this option to pass the Wsdl.exe tool a large number of options at one time. Short form is /par:. Option elements are contained inside a <wsdlParameters xmlns="https://microsoft.com/webReference/"> element. For details, see the Remarks section.

/parsableerrors

Displays errors in a format similar to the error reporting format used by language compilers. When using the /parameters option, this value is the <parsableerrors> element and is either true or false.

/p[assword]:password

Specifies the password to use when connecting to a server that requires authentication. When using the /parameters option, this value is the <password> element and contains a string.

/protocol:protocol

Specifies the protocol to implement. You can specify SOAP (default), HttpGet, HttpPost, or a custom protocol specified in the configuration file. When using the /parameters option, this value is the <protocol> element and contains a string.

/proxy:URL

Specifies the URL of the proxy server to use for HTTP requests. The default is to use the system proxy setting. When using the /parameters option, this value is the <proxy> element and contains a string.

/proxydomain:domain

or

/pd:domain

Specifies the domain to use when connecting to a proxy server that requires authentication. When using the /parameters option, this value is the <proxydomain> element and contains a string.

/proxypassword:password

or

/pp:password

Specifies the password to use when connecting to a proxy server that requires authentication. When using the /parameters option, this value is the <proxypassword> element and contains a string.

/proxyusername:username

or

/pu:username

Specifies the user name to use when connecting to a proxy server that requires authentication. When using the /parameters option, this value is the <proxyusername> element and contains a string.

/server

Generates an abstract class for an XML Web service based on the contracts. The default is to generate client proxy classes. When using the /parameters option, this value is a <style> element that contains "server".

/serverInterface

Generates interfaces for server implementation of an ASP.NET Web Service. An interface is generated for each binding in the WSDL document(s). The WSDL alone implements the WSDL contract (classes that implement the interface should not include either of the following on the class methods: Web Service attributes or Serialization attributes that change the WSDL contract). Short form is /si. When using the /parameters option, this value is a <style> element that contains "serverInterface".

/sharetypes

Turns on the type sharing feature. This feature creates one code file with a single type definition for identical types shared between different services (the namespace, name, and wire signature must be identical). Reference the services with "http://" URLs as command-line parameters or create a discomap document for local files. When using the /parameters option, this value is the <sharetypes> element and is either true or false.

/u[sername]:username

Specifies the user name to use when connecting to a server that requires authentication. When using the /parameters option, this value is the <username> element and contains a string.

/?

Displays command syntax and options for the tool.

A .wsdl file is an XML document written in an XML grammar called Web Services Description Language (WSDL). This file defines how an XML Web service behaves and instructs clients as to how to interact with the service.

You can obtain discovery documents for an XML Web service using the Web Services Discovery Tool (Disco.exe). The .discomap, .disco, .wsdl, and .xsd files produced by this tool can be used as input to Wsdl.exe.

When you use Wsdl.exe to create a proxy class, a single source file is created in the programming language that you specify. In the process of generating the source code for the proxy class, the tool determines the best type to use for objects specified in the service description. In some cases, the tool uses a least-common-denominator approach for casting objects to a type. As a result, the generated type in the proxy class might not be what the developer wants or expects. For example, when Wsdl.exe encounters an ArrayList type in a service description, it creates an Object Array in the generated proxy class. To ensure correct object type casts, open the file that contains the generated proxy class and change any incorrect object types to the expected object type.

  • The /parameters option specifies a file that contains elements that correspond to most of the command-prompt options. Some command-prompt options are available only in the /parameters file formats.

The XML file format accepted by the /parameters option is a series of elements inside an outer <wsdlParameters xmlns="https://microsoft.com/webReference/"> element. If command-prompt values are specified and a /parameters file is used that contains different options or values, the values specified at the command prompt are used. The <wsdlParameters xmlns="https://microsoft.com/webReference/"> element must contain a <nologo> element, a <parsableerrors> element, and a <sharetypes> element.

Several options are passed as child elements of the <webReferenceOptions> element, which must contain a <verbose> element. Other child elements of <webReferenceOptions> are:

  • <style>. Contains either "client", "server", or "serverInterface".

  • <schemaImporterExtension>. Contains any number of <type> elements.

  • <codeGenerationOptions>. Can take a space-delimited set of the following strings.

  • "properties"

  • "newAsync"

  • "oldAsync"

  • "order"

  • "enableDataBinding"

See the following Examples section for some demonstrations of the /parameters option.

Examples

The following command creates a client proxy class in the C# language for the XML Web service.

wsdl http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL

The following command creates a client proxy class in the C# language for an XML Web service located at the specified URL. The tool saves the client proxy class in the file myProxyClass.cs.

wsdl /out:myProxyClass.cs http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL

The following command creates a client proxy class in the Microsoft Visual Basic language for an XML Web service located at the specified URL. The tool saves the client proxy class in the file myProxyClass.vb.

wsdl /language:VB /out:myProxyClass.vb http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL

The following example code shows a basic /parameters WSDL file with only the required elements written that can be used, combined with a URL argument, at the command prompt.

<wsdlParameters xmlns="https://microsoft.com/webReference/">
  <nologo>true</nologo>
  <parsableerrors>true</parsableerrors>
  <sharetypes>true</sharetypes>
</wsdlParameters>

WSDL documents are added in the /parameters WSDL file using the <documents> element, as the following code example demonstrates. Any number of <document> elements can be used inside the <documents> element.

<wsdlParameters xmlns="https://microsoft.com/webReference/">
  <nologo>true</nologo>
  <parsableerrors>true</parsableerrors>
  <sharetypes>true</sharetypes>
  <documents>
    <document>https://www.contoso.com/service.asmx?WSDL</document>
  </documents>
</wsdlParameters>

The following /parameters WSDL file demonstrates the use of the <codeGenerationOptions> and <style> elements inside the <webReferenceOptions> element. In this case, the file enables the new style of data binding in proxy code, specifies a schema importer extension that output is not to be verbose, and that Wsdl.exe is to create a client proxy.

<wsdlParameters xmlns="https://microsoft.com/webReference/">
  <nologo>true</nologo>
  <parsableerrors>true</parsableerrors>
  <sharetypes>true</sharetypes>
  <documents>
    <document>https://www.contoso.com/service.asmx?WSDL</document>
  </documents>
  <webReferenceOptions>
    <verbose>false</verbose>
    <codeGenerationOptions>properties newAsync enableDataBinding</codeGenerationOptions>
    <schemaImporterExtension>
      <type>MyNamespace.MyCustomImporterExtension,ExtensionLibrary</type>
    </schemaImporterExtensions>
    <style>client</style>
  </webReferenceOptions>
</wsdlParameters>

See Also

Reference

Web Services Discovery Tool (Disco.exe)

Concepts

Creating an XML Web Service Proxy
XML Web Service Description
XML Web Services Overview

Other Resources

.NET Framework Tools
SDK Command Prompt