spacer
Yehuda Shiran November 18, 2001
Checking the result Object
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

When you call a Web service, you actually send a message to the service and then receive another message as a response. You send a message via the callService() method. Here is an example for calling a Web service in Internet Explorer:

iCallID = webServiceCallerBody.echo.callService(handleResult, "echoString", 
  "Asynchronous Call");
The response message, or errors encountered during the interaction with the Web service, are attached to an object, called the result object. If you want to find the result of your query to the Web service, you need to analyze the result object. First, you need to know where you can get it for analysis. Well, it depends on how you call the Web service. If you specify an event handler in the callService() method (first parameter), the result object will be passed as a parameter to this event handler. Here is the handleResult() function from the above callService() example:

function handleResult(res) {
  if (!res.error) {
    alert("Successful call. Result is " + res.value);
  }
  else {
    alert("Unsuccessful call. Error is " + res.errorDetail.string);
  }
}
If you don't specify an event handler in the callService() method, you can get the result object as a property of the event object. You first specify the onresult event handler like here:

<BODY ID="webServiceCallerBody" onresult="onWSresult()" 
style="behavior:url(webservice.htc)">
And you define the onWSresult() as follows:

function onWSresult() {  
  if((event.result.error) ...
}

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
DiVitas's Mobile UC Now Available on the Latest Devices · Review: FON Fonera 2.0n · Chip Market Recovering From '08 Collapse