日期:2008-10-26  浏览次数:20411 次

HOW TO: BETA: Integrate a .NET Client with an Apache SOAP 2.2 XML Web Service

--------------------------------------------------------------------------------
The information in this article applies to:

Microsoft Visual Studio .NET Beta 2

--------------------------------------------------------------------------------
This article discusses a Beta release of a Microsoft product. The information in this article is provided as-is and is subject to change without notice.

No formal product support is available from Microsoft for this Beta product. For information about obtaining support for a Beta release, please see the documentation included with the Beta product files, or check the Web location from which you downloaded the release.
IN THIS TASK
SUMMARY
Requirements
Prepare WSDL File for .NET
Create the Proxy
Use the Wsdl.exe Tool to Create the Proxy
Use the Visual Studio .NET IDE to Create the Proxy


SUMMARY
This article describes how to integrate a .NET client with an Apache SOAP 2.2-based Web service. This article assumes that a Web Services Description Language (WSDL) file exists and was created by using the IBM Web Services Toolkit.

back to the top

Requirements
This article assumes that you are familiar with the following topics:
Reading and editing WSDL files
Microsoft .NET Framework Software Development Kit (SDK)
back to the top
Prepare the WSDL File for .NET
The IBM Web Services Toolkit places the WSDL information in two files:
Java class name _Service.wsdl (the service file)
Java class name _Service-interface.wsdl (the interface file)
The first file contains the service information. The second file contains the message, port type, and binding definitions. Because of incompatibilities between IBM-generated WSDL and the Microsoft .NET WSDL implementation, you must edit the files that the IBM Web Services Toolkit generates so that the .NET environment can read them in.

NOTE : The .NET environment can handle WSDL imports. However, the WSDL that the IBM Web Services Toolkit generates improperly uses the targetNamespace attribute and incorrectly references other internal elements (specifically, the <binding>, <message>, and <portType> elements). The easiest and quickest approach is to merge and edit the files as follows:
Copy both .wsdl files to your computer.


Open the service file, and delete the <import> element.


Open the interface file, and copy all of the elements except for the <definitions> tags. Paste these elements into the service file above the <service> element.


In the <portType> element, append the "tns:" string to the message attribute values on the <input> and <output> child elements.


In the <binding> element, append the "tns:" string to the type attribute value.


In the <service> element, append the "tns:" string to the binding and name attribute values on the <port> child element.


For the root-level <definitions> element, set xmlns:xsd namespace to reference http://www.w3.org/2001/XMLSchema URI (that is, change "1999" to "2001").


back to the top
Create the Proxy
To create the proxy, you can use either of the following methods:
Use the Wsdl.exe tool, and include the file in a project.
Create a Web reference from within the Microsoft Visual Studio .NET Integrated Development Environment (IDE).
After you create the proxy, you can use the proxy as you would any other Microsoft .NET class.

back to the top
Use the Wsdl.exe Tool to Create the Proxy
From the Start menu, point to Programs , point to Microsoft Visual Studio .NET , point to Visual Studio .NET Tools ,