Monday, June 22, 2009

Creating the Web Service Proxy using wsdl

Creating the Web Service Proxy

A client and a Web service can communicate using SOAP messages, which encapsulate the input and output parameters as XML. A proxy class maps parameters to XML elements and then sends the SOAP messages over a network. In this way, the proxy class frees you from having to communicate with the Web service at the SOAP level and allows you to invoke Web service methods in any development environment that supports SOAP and Web service proxies.

There are two ways to add a proxy class to your development project using the Microsoft .NET Framework: with the WSDL tool in the .NET Framework, and by adding a Web reference in Microsoft Visual Studio. The following sections discuss this subject in further detail.

Adding the Proxy Using the WSDL Tool
The .NET Framework SDK includes the Web Services Description Language tool (Wsdl.exe), which enables you to generate a Web service proxy for use in the.NET Framework development environment. The most common way to create a client proxy in languages that support Web services (currently C# and Microsoft Visual Basic) is to use the WSDL tool.

To add a proxy class to your project using Wsdl.exe

From a command prompt, use Wsdl.exe to create a proxy class, specifying (at a minimum) the URL to the Report Server Web service.
For example, the following command prompt statement specifies a URL for the management endpoint of the Report Server Web service:
Copy Code
wsdl /language:CS /n:"Microsoft.SqlServer.ReportingServices2005" http://myserver/reportserver/reportservice2005.asmx?wsdl
The WSDL tool accepts a number of command-prompt arguments for generating a proxy. The preceding example specifies the language C#, a suggested namespace to use in the proxy (to prevent name collision if using more than one Web service endpoint), and generates a C# file called ReportingService2005.cs. If the example had specified Visual Basic, the example would have generated a proxy file with the name ReportingService2005.vb. This file is created in the directory from which you run the command.

Compile the proxy class into an assembly file (with the extension .dll) and reference it in your project, or add the class as a project item.
When you add a proxy class to your project manually, you need to add a reference to System.Web.Services.dll. If you add the proxy using a Web reference in Visual Studio .NET, the reference is automatically created for you. For more information, see "Adding the Proxy Using a Web Reference in Visual Studio" later in this topic.

No comments:

Post a Comment