Share via


WSDL to SoapClient Tool (WseWsdl2.exe)

The WSDL to SoapClient tool generates proxy code for Web service clients from WSDL files. The generated proxy code contains a class that derives from the SoapClient class. Use this generated class to send SOAP messages to SOAP receivers.

WseWsdl2 {URL | path} [Options] filename
Argument Description

URL

The URL to a WSDL file (.wsdl).

path

The path to a local WSDL file (.wsdl).

filename

Specifies the file in which to save the generated proxy code. The generated proxy code is a class derived from SoapClient.

Option Description

-language <language>

Specifies the language to use for the generated proxy class. You can specify CS (C#; default) or VB (Visual Basic) as the language argument.

-name <logical name>

Specifies the logical name for the Web service. Use the –name option when the proxy class requires an EndpointReference that has a Via property.

-noRecursion

Specifies that the WSDL to SoapClient tool does not download WSDL documents specified within <import> elements. The -noRecursion option takes precedence over the -recursionLevel option.

-recursionLevel <number of levels>

Specifies how many levels of recursion the WSDL to SoapClient tool goes through when downloading WSDL documents within <import> elements. The -noRecursion option takes precedence over the -recursionLevel option. The default value is 3.

<schema file>language

Any schema files that are referenced by the WSDL document.

The WSDL to SoapClient tool supports the following types of .wsdl files:

WSDL file Description

Document/Literal Web services

The RPC style and SOAP encoding are not supported.

WSDL files with more than one binding under a service

Only document/literal SOAP bindings are generated. Only TCP and HTTP transport bindings are supported.

URLs to WSDL descriptions can be either HTTP or soap.tcp.

HTTP locations use a GET request. Soap.tcp locations are retrieved with a SOAP message ("GetDescription").

WSDL files without <service> elements

Classes are generated for all supported bindings in this case, but no location is set on the generated code. If there are <service> elements, then classes are generated for all subordinate bindings of those – code is not generated for orphaned bindings. Therefore, if the .wsdl file contains a <service> element, it must have at least one <port> child element.

Only one address per <port> element

WSDL files that contain more than one address per <port> element are not supported.

Remarks

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

The WSDL to SoapClient tool (WseWsdl2.exe) tool can process WSDL documents that have nested <import> elements. That is, WSDL documents that contain an <import> element that references a WSDL document, which in turn has an <import> element that references another WSDL document, and so forth. To specify the level of recursion that the WSDL to SoapClient tool goes through to download the imported WSDL documents, use the -noRecursion and -recursionLevel command line parameters. To specify how many levels of recursion you want the tool to go through, use the -recursionLevel option followed by an integer that represents the number of levels or documents you want the tool to go through. If you do not want the tool to download WSDL documents specified in <import> elements, use the -noRecursion command line parameter. If both parameters are used, the -noRecursion parameter takes precedence.

When you use the WSDL to SoapClient tool to create a proxy class, a single source file is created in the programming language that you specify. The type defined in the Web service may be different than the type generated in the proxy class. In some cases the WSDL to SoapClient 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 you want or expect. For example, when the WSDL to SoapClient tool encounters an ArrayList type in a service description, it creates an array of type Object 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.

Note

Sometimes the WSDL to SoapClient tool fails to generate a proxy class for SoapService Web services that are accessed using the TCP protocol, because of the Web service's policy. Policy is enforced by WSE for all SOAP messages sent to the endpoint, including the SOAP message sent by the WSDL to SoapClient tool to retrieve the Web service's WSDL file. That SOAP message is sent with a SOAP action of https://schemas.microsoft.com/wse/2003/06/RequestDescription. Therefore, to allow the WSDL to SoapClient tool to retrieve a WSDL file for the Web service, in the policy file specify that there are no requirements for SOAP messages sent to the Web service's endpoint with a SOAP action of https://schemas.microsoft.com/wse/2003/06/RequestDescription.

The following code example, which is a portion of a valid policy file, allows the WSDL to SoapClient tool to obtain the WSDL file for the soap:tcp//www.cohowinery.com/OrderWine endpoint.

<mappings>
  <endpoint uri="soap:tcp//www.cohowinery.com/OrderWine">
    <operation requestAction="https://schemas.microsoft.com/wse/2003/06/RequestDescription">
      <request policy="" />
    </operation>
    <operation requestAction="soap:tcp//www.cohowinery.com/OrderWine">
      <request policy="#OrderWinePolicy" />
      <response policy=""/>
      <fault policy=""/>
    </operation>
  </endpoint>
</mappings>

Example

The following command creates a client proxy class in C# for a Web service located at the specified URL. The WSDL to SoapClient tool saves the client proxy class in the file MyProxyClass.cs.

WseWsdl2 http://hostServer/WebServiceRoot/WebServiceName.asmx?WSDL MyProxyClass.cs

The following command creates a client proxy class in Visual Basic for a Web service located at the specified URL. The WSDL to SoapClient tool saves the client proxy class in the file MyProxyClass.vb.

WseWsdl2 http://hostServer/WebServiceRoot/WebServiceName.asmx?WSDL MyProxyClass.vb VB

See Also

Reference

SoapClient

Other Resources

WSE Tools
Sending and Receiving SOAP Messages