WSDL to Proxy Class Tool

The WSDL to Proxy Class tool generates proxy code for Web service clients from WSDL files. The generated proxy code contains a class that derives from the WebServicesClientProtocol class or the SoapClient class depending upon the type option. Use this generated class to send SOAP messages to SOAP receivers.

Note

To have the WSDL to Proxy Class tool generate a proxy class that derives from the WebServicesClientProtocol class, the .NET Framework SDK 2.0 WSDL.exe tool must be installed and accessible. When the SDK Command Prompt is used to run the WSDL to Proxy Class tool, the WSDL.exe tool is accessible.

WseWsdl3 {URL | path} [Options]
Argument Description

URL

The URL to a WSDL file (.wsdl).

path

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

Option Description

/f[ields]

Generates fields instead of properties.

/l[anguage]:language

Specifies the language to use for the generated proxy class. You can specify CS (C#), VB (Visual Basic), JS (JScript), or VJS (J#) as the language argument. The default is CS.

/n[amespace]:namespace

Specifies the namespace for the generated proxy or template. The default namespace is the global namespace.

/nologo

Suppresses the banner that is typically displayed by the WSDL to Proxy Class tool.

/order

Generate explicit order identifiers on particle members.

/o[ut]:filename

Specifies the file in which to save the generated proxy code. The tool derives the default file name from the Web service name.

/protocol:protocol

Specifies the protocol to implement. You can specify SOAP (default), SOAP12, HttpGet, or HttpPost

/type:proxyType

Specifies the type of proxy class to generate. Possible values are webClient and soapClient. webClient creates a proxy class that derives from the WebServicesClientProtocol class. soapClient creates a proxy class that derives from the SoapClient class. The soapClient option only works for Web services that derive from the SoapService class. The default value is soapClient.

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

WSDL file Description

Document/Literal Web services

When the soapClient type of proxy class is used, 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.

Operations can have 0 or 1 parameters

When the soapClient type of proxy class is used, operations, which are also known as Web service methods, can only have 0 or 1 parameters.

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.

When you use the WSDL to Proxy Class 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 Proxy Class 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 Proxy Class 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 Proxy Class 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 Proxy Class 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 Proxy Class 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.

When a proxy class that derives from WebServicesClientProtocol is created for a Web service that is hosted outside of IIS, some of the properties that are specific to HTTP are unavailable. The following paragraphs summarize those properties.

The following properties of the WebServicesClientProtocol class:

  • AllowAutoRedirect
  • CookieContainer
  • PreAuthenticate
  • UserAgent

When the GetWebRequest method is overridden, the following properties are unavailable:

  • Cookies
  • Headers
  • PreAuthenticate

The following code example, which is a portion of a valid policy file, allows the WSDL to Proxy Class 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 Proxy Class tool saves the client proxy class in the file MyProxyClass.cs.

WseWsdl3 http://hostServer/WebServiceRoot/WebServiceName.asmx?WSDL /out: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 Proxy Class tool saves the client proxy class in the file MyProxyClass.vb.

WseWsdl3 http://hostServer/WebServiceRoot/WebServiceName.asmx?WSDL /out:MyProxyClass.vb /language:VB

The following command creates a client proxy class that derives from the WebServicesClientProtocol class for a Web service that is accessible using the TCP protocol. The WSDL to Proxy Class tool saves the client proxy class in the file MyProxyClass.cs.

wsewsdl3.exe soap.tcp://localhost/TcpStockService MyProxyClass.cs /type:webClient

See Also

Reference

WebServicesClientProtocol
SoapClient

Other Resources

WSE Tools
Sending and Receiving SOAP Messages Using WSE Messaging API