spacer
Yehuda Shiran November 27, 2001
Web Service Basic Authentication
Tips: November 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

Some Web services require basic authentication. Usually, they require a user name and a password. You need to send these two items to the Web service via the call object. You just assign the appropriate properties of the call object:

function callSynch() {
  var co = webServiceCallerBody.createCallOptions();
  co.funcName = "echoString";
  co.async = false;
  co.userName = "guest";
  co.password = "guest";
  var oResult = webServiceCallerBody.echo.callService(co, "Synchronous Call");
  handleResult(oResult);
} 
The ID webServiceCallerBody is the ID of the element to which you attach the WebService behavior, like here:

<BODY ID="webServiceCallerBody" onload="loadService()" 
  STYLE="behavior:url(webservice.htc)>
And the function callSynch() is called by clicking a button:

<BUTTON ID="b2" onclick="callSynch()" disabled>Call Synchronously</BUTTON>
Some Web services require the exact port number that you are trying to connect to. You specify it with the port property of the call object, like here:

function callSynch() {
  var co = webServiceCallerBody.createCallOptions();
  co.funcName = "echoString";
  co.async = false;
  co.userName = "guest";
  co.password = "guest";
  co.port = "Port1";
  var oResult = webServiceCallerBody.echo.callService(co, "Synchronous Call");
  handleResult(oResult);
} 

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 >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint