August 3, 2002 - Creating a Proxy for IsPrime | WebReference

August 3, 2002 - Creating a Proxy for IsPrime

Yehuda Shiran August 3, 2002
Creating a Proxy for IsPrime
Tips: August 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Creating a proxy for a Web service is a two-step process. The first step creates the proxy code in JScript .NET and adds your class to the specified namespace. The executable that does this is wsdl.exe. Your .NET Framework should support this executable by including its directory in your path. Open a Command Prompt window and cd (change directory) to your working directory, d:\aspDemo for example. Type wsdl and verify you get the help for this executable. Type the full command now (in one line):

wsdl /l:js /namespace:primeProxy /out:sampleProxy.js 
The last entry on this line is the input to the wsdl command:

which is the full path to the Web service definition. The other switches are:

/l: specified the language of the input file. Put js for JScript.
  • /namespace: specifies to which namespace you want to add your new primeNumbers class. The .NET framework will create a new namespace if it does not find one in its archive. The .NET framework stores the class definition somewhere on a system directory and you don't have to worry about it ever.
  • /out: specifies the name of the JScript file that will be created. This file is the proxy for the Web service. Put sampleProxy.js, for example. This switch specifies where the proxy will be saved. If you don't specify a directory before the file name, the proxy will be saved in your current directory (d:\aspDemo in our case).

    The following Command Prompt window shows the content of checkIsPrime.asmx and the echo of the wsdl command:

    To learn more about JScript .NET and ASP.NET, go to Column 114, JScript .NET, Part VIII: Consuming IsPrime from ASP.NET.