JScript .NET, Part VI: Creating IE Web Services - Doc JavaScript
JScript .NET, Part VI: Creating IE Web Services
In this column we continue our series on JScript .NET. In Part I, we laid down the groundwork for JScript .NET, showing you how to install IIS and the .NET SDK, and how to compile and run a JScript .NET program. In Part II, we showed you the major differences between JavaScript and JScript .NET. In Part III, we focused on JScript .NET's classes and their division among namespaces. In Part IV we taught you how to use inheritance in classes and interfaces. In Part V, we covered the third holy grail of object oriented programming: polymorphism. In this column, we'll show you how to define Web services in JScript .NET and how to consume them.
In our previous 11-part series on Web services, Columns 96 to 106, we showed you how to consume Web services on other domains. In the current series, we've covered the subject of JScript .NET. You can use JScript .NET to define your own Web services and install them on your IIS Web server. In this column, we'll show you how to combine what you have learned from the Web service series with what you have learned from the JScript .NET series. We'll teach you how to define and consume Web services. We'll use two examples: add
and IsPrime
.
Unzip the attached file and put the two included asmx
files in a new directory: c:\inetpub\wwwroot\Webreference
. Put the files example.html
and webservice.htc
in a separate directory anywhere on your hard drive, and then load example.html
in your browser. For example, if you placed the example.html
and webservice.htc
files in the directory c:\docjs
, then you would load the example by typing this URL into your browser: c:\docjs\example.html
. Try both Web services and see that you get correct answers.
These Web service examples work properly in Internet Explorer browsers, version 5.5 or later. You also need to have the IIS Web server installed, as well as the .NET SDK. Well, hopefully you have them by now; otherwise you have missed out on some great stuff in our current series on JScript .NET. See Column 107 for details.
In this column you will learn:
- How to create a Web service
- How to interact with the
add
Web service - How to interact with the
IsPrime
Web service - How to write a GUI for consuming the
add
andIsPrime
Web services - How to script a page that consumes the
add
andIsPrime
Web services from IE
The following files were zipped for you: checkIsPrime.asmx
(the IsPrime
Web service), simpleCalc.asmx
(the add
Web service), add.html
(a consumer of the add
Web service), isprime.html
(a consumer of the IsPrime
Web service), example.html
(a consumer of both services) and webservice.htc
(the DHTML behavior).
Next: How to create a Web service
Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: June 17, 2002
Revised: June 17, 2002
URL: https://www.webreference.com/js/column112/index.html