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

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, 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