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

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

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, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business