spacer
Yehuda Shiran July 14, 2002
Initializing Web Service Consumption
Tips: July 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Google Going Native With Chrome
Mozilla Fixes Firefox Flaws as 3.5 Release Nears
Microsoft and Novell Still Bosom Buddies

When you want to consume your own Web services, put them (asmx files) in a sub-directory of your Web server, such as c:\inetpub\wwwroot\Webreference. Then, when you access the services in your scripts, you refer to their directory as http://localhost/Webreference. For each Web service you consume you need to have three JavaScript functions:

  • The init() function assigns a short name to the Web service URL
  • A function to call the Web service with the appropriate parameters
  • A function to display the results

The init() function can be shared among Web services. You invoke it upon loading of the page, onload=init(). We call the webservice behavior's useService() method to assign short identifiers to the Web service's rather-long URL. We call the add Web service by "simpleCalcWebService" and the IsPrime Web service by "isPrimeNumberWebService":

  function init() {
    myWebService.useService("
      http://localhost/Webreference/checkIsPrime.asmx?WSDL",
      "isPrimeNumberWebService");
    myWebService.useService("http://localhost/Webreference/simpleCalc.asmx?WSDL",  
      "simpleCalcWebService");
  }
To learn more about JScript .NET, go to Column 112, JScript .NET, Part VI: Creating IE Web Services.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
XML and PHP Simplified · Creating a ASP.NET Contact Form · Data Filtering with PHP
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Intel to Host Live Nehalem Q&A · 12 Tips to Troubleshoot Network File-Sharing · 10 Tips for Selling on Kijiji