onresult Event

This topic documents a feature of Binary Behaviors, which are obsolete as of Internet Explorer 10.

Fires when a result has been received from a remote method callService using the WebService behavior.

Syntax

Event Property WebService.onresult = handler;
attachEvent WebService.attachEvent( "onresult", handler);
Named script <SCRIPT FOR = WebService EVENT = onresult>

Event Information

Bubbles No
Cancels No
To invoke Run the callService method on the WebService behavior.
Default action Initiates the script handler or callback function associated with the onresult event.

Remarks

The onresult event is only available to objects in the document to which the WebService behavior is attached. If a callback handler function is specified to process the results returned by a method callService, then the onresult event is not fired.

The following subproperties of the event object are available.

  • result.id

    Returns a unique identifier that is associated with a particular instance of a method call.

  • result.value

    Returns the value, or values, of the method call. The data type returned depends on the definition of the method in the service description.

  • result.raw

    Returns the whole XML data island received from the server, including the packet headers and envelope when SOAP is used.

In addition to providing the value and raw properties, the result object also provides the following properties, which contain error diagnostic information.

  • result.error

    Returns a Boolean. If true, the method call resulted in an error; if false, the method was called successfully.

If result.error is true then the errorDetail object is available, exposing the following set of properties.

Note  If result.error is false then no error has occurred, and the errorDetail object is not available.

Example

The following sample code shows how the onresult event can be used to determine if a method call returned successfully.

<SCRIPT language="JavaScript">
var iCallID;

function init()
{
    service.useService("/services/math.asmx?WSDL","MyMath");
    iCallID = service.MyMath.callService("add",5,6);
}

function onWSresult()
{  
    if((event.result.error)&&(iCallID==event.result.id))  
    {    
        var xfaultcode   = event.result.errorDetail.code;
        var xfaultstring = event.result.errorDetail.string;    
        var xfaultsoap   = event.result.errorDetail.raw;
        document.writeln("ERROR. Method call failed!");
        document.writeln("Call ID:" + iCallID);
        document.writeln("Fault Code:" + xfaultcode);
        document.writeln("Fault String:" + xfaultstring);
        document.writeln("SOAP Data:" + xfaultsoap);
    }
    else if(event.result.error == false)
    {
        document.writeln("Result received without errors!");
    }
}
</script>
<body onload="init()">
<div id="service" style="behavior:url(webservice.htc)" onresult="onWSresult()">
</div>
</body>

Applies To

WebService

See Also

callService, useService, Using the WebService Behavior, About the WebService Behavior