by Chris Peiris
Creating a Proxy Web Service Object

By replicating a Web service's functionality on a local server, you can circumvent the security and data marshalling problems inherent in this distributed application technology. Use a proxy object to act on behalf of the original Web service.


ecause a proxy object is the basic concept of a Web service invocation, your first step in creating a Web service client is to create a proxy object. Then you can use multiple platforms (Web browsers, WAP clients, PDAs, and SOAP clients) to extract data from the it.

What you need:
Basic knowledge of .NET Web services, the .NET platform, C#, object-oriented concepts, Visual Studio .NET (Beta 2 available here), and Microsoft's .NET Mobile Internet Tool Kit (Beta 2 available here).

There is a utility called Wsdl.exe in the .NET Framework that you can use to create a proxy Web service object. (In Beta 1 this utility is called WebServiceUtil.exe.) Use an MS-DOS prompt window to create a proxy object. Table 1 lists the options available for proxy creation in Beta 1 and Table 2 lists the options for Beta 2.

The minimum syntax is shown here:

In Beta 1:

WebServiceUtil /c:proxy /pa:
http://yourDomain/someFolder/yourWebService.asmx?SDL

In Beta 2:

wsdl 
http://yourDomain/someFolder/yourWebService.asmx?WSDL
Let's use an example and create a proxy object.

In Beta 1:

WebServiceUtil 
/c:proxy /pa: 
http://www22.brinkster.com/prasads/LiveQuoteService.asmx?SDL 
/l:CSharp /n:WebServiceClients

In Beta 2:

wsdl /l:CSharp /n:WebServiceClients 
http://www22.brinkster.com/prasads/LiveQuoteService.asmx?WSDL
This command creates the LiveQuote.cs file in the current directory. It is a C# file in the WebServiceClients namespace. You will recognize the importance of creating WebServiceClients namespace when you create the clients.

In Beta 1 you need to compile the C# class. This generates a DLL to link to your client projects. Put this under the "bin" directory.

In Beta 1:

csc /t:library /t:library /r:System.Xml.Serialization dll 
/r:System.Web.Services.dll /out:bin/ LiveQuotes.dll LiveQuotes.cs

This creates LiveQuotes.dll under the "bin" directory. If you need to read about compiling a C# class, refer to the .NET SDK help (see the article in the .NET Framework Developer's Guide called "Creating ASP.NET Web Applications").

It's simple as that. With just two commands you can create a proxy object, which allows you to extract data from a Web service. This proxy object has the complete public interface for any sophisticated business logic functions. You don't even need to register the DLL. You just compile the source code and stick the DLL in the "bin" directory; the .NET Framework picks it up at runtime. This is sufficient to get access to the DLL by the Web server.

Note: In Beta 2 you do not need to create a separate DLL to add to your project. You can simply add the proxy class module to your C# project in the Visual Studio.NET IDE. This process will be illustrated in future articles.

Now that you got the proxy object running, the next step is to look at creating the clients.

  Creating a WAP Client

Chris Peiris Chris Peiris is a systems architect for IT & E-Commerce in Melbourne, Australia. He has designed and developed Microsoft Web solutions since 1995. His expertise lies in developing scalable, high-performance Web solutions for financial institutions and media groups. He also teaches at Monash University in Caulfield, Australia. His core skills are C++, Java, .NET, DNA, MTS, Site Server, Data Warehousing, WAP, and SQL Server. He can be reached at www.chrispeiris.com.
 

What do you think about .NET Web services? How soon will you build them? Join the discussion!
Click here to talk

What do you think of this series?


Sponsored Links

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map
Jupiterweb networks

internet.comearthweb.comDevx.comClickZ

Search Jupiterweb:

Jupitermedia Corporation has four divisions:
JupiterWeb, JupiterResearch, JupiterEvents, and JupiterImages

Copyright 2004 Jupitermedia Corporation All Rights Reserved.
Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Jupitermedia Corporate Info | Newsletters | Tech Jobs | E-mail Offers

Copyright Information/Privacy Statement