JScript .NET, Part VII: Consuming add from ASP.NET: Creating a Proxy - Doc JavaScript
JScript .NET, Part VII: Consuming add from ASP.NET
Creating a Proxy
Let's create a proxy for the add
Web service from Column 112. We put all files in d:\aspDemo
, including the Web service definition, simpleCalc.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. We chose Column113
. 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 add
Web service via https://localhost/Column113/simpleCalc.asmx
(assuming you put simpleCalc.asmx
in d:\aspDemo
).
Now you can start creating the proxy to the add
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:calcService /out:calcProxy.js https://localhost/Column113/simpleCalc.asmx
The last entry on this line is the input to the wsdl
command:
https://localhost/Column113/simpleCalc.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 newsimpleCalc
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. PutcalcProxy.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 simpleCalc.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: June 30, 2002
Revised: June 30, 2002
URL: https://www.webreference.com/js/column113/4.html