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.