Web Services, Part IV: WebService Behavior's Objects, Properties, and Events
The onresult Event Handler
onresult event fires when a result has been received from a remote Web service using the
WebService behavior. It is only available to objects in the document to which the
WebService behavior is attached. Here is an example that shows how to specify this event handler:
<DIV ID="service" STYLE="behavior:url(webservice.htc)" onresult="onWSresult()">
You cannot specify both an
onservice event handler and a function callback for the
callService() method. If you do specify them both, the
onresult event will not fire.
All properties of the event object are generally available in the
Result object. They are:
- result.id. Returns a unique identifier that is associated with a particular instance of the
result.value. Returns the value, or values, of the method call. The data type returned depends on the the definition of the method in the service description.
result.raw. Returns the whole XML data received from the server, including the packet headers and envelopes when SOAP is used.
result.error. Returns a Boolean, specifying if there has been an error. If
true, the method call resulted in an error; if
false, the method was called successfully.
true (an error occurred), the
errorDetail object is available as a property of the
result.errorDetail.code. A cryptic error code. Can be
result.errorDetail.string. A more descriptive error message. For example:
"Error is Invalid argument."
result.errorDetail.raw. The entire XML data packet, received from the server.
The following example shows how to use the
onresult event handler:
Next: A Final Word