JScript .NET, Part VIII: Consuming IsPrime from ASP.NET: Creating a Proxy - Doc JavaScript
JScript .NET, Part VIII: Consuming IsPrime from ASP.NET
Creating a Proxy
Let's create a proxy for the IsPrime
Web service from Column 112. We put all files in d:\aspDemo
, including the Web service definition, checkIsPrime.asmx
. Now you need to open the IIS control window. In Windows XP, click start
-> Control Panel
-> Performance and Maintenance
-> Administrative Tools
-> Internet Information Services
. Expand the menu by clicking the +
button, until you get the Default Web Sites
entry:
Let's create a virtual directory now under Default Web Sites
. Right-click the Default Web Sites
entry, and pick New Virtual Directory
. A wizard will guide you through two entries and a set of options. The first entry is the alias of this Web site. Since our filenames will all be different from Column 113's, we'll continue to use the Column113
alias that we created in our previous tutorial. Then it will ask you for the path of the directory where the content is. Browse to your directory and press Next
. We chose d:\aspDemo
. Leave the last page as is and click Finish
. You will now see all your files from d:\aspDemo
reflected in the right window of the IIS control panel. You can check now that indeed you can see the IsPrime
Web service via https://localhost/Column113/checkIsPrime.asmx
(assuming you put checkIsPrime.asmx
in d:\aspDemo
).
Now you can start creating the proxy to the IsPrime
Web service. It's 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 d:\aspDemo
. 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 https://localhost/Column113/checkIsPrime.asmx
The last entry on this line is the input to the wsdl
command:
https://localhost/Column113/checkIsPrime.asmx
which is the full path to the Web service definition. The other switches are:
/l:
specified the language of the input file. Putjs
for JScript./namespace:
specifies to which namespace you want to add your newprimeNumbers
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. PutsampleProxy.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:
Next: How to create a .dll file
Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: July 15, 2002
Revised: July 15, 2002
URL: https://www.webreference.com/js/column114/2.html