Export (0) Print
Expand All
3 out of 4 rated this helpful - Rate this topic

call Object

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

A script object that can be passed as a parameter to the callService method.

Members Table

The following table lists the members exposed by the call object.

Attributes/Properties
Property Description
async Specifies the mode of remote method invocation.
endpoint A property of the call object that specifies an URL that can be used to obtain the Web Services Description Language (WSDL) for a Web Service.
funcName Specifies the name of a remote function exposed by a Web Service.
params A property of the call object that specifies an associative array of parameter values.
password Specifies a password for Web Services that require user authentication.
portName Specifies a port name that is used to access resources provided by a Web Service.
SOAPHeader An Array of SOAP headers that overrides the default SOAP header generated by the WebService behavior.
timeout Not supported.
userName Specifies a user name for Web Services that require user authentication.

Remarks

The call object is used to specify additional parameters and information that are sometimes required by Web Services.

By default, the WebService behavior processes remote method invocations asynchronously. In order to specify the synchronous mode of operation, the async property of the call object must be set to false. Therefore, the call object must be passed to the fo parameter of the callService method in order for the WebService behavior to process remote methods synchronously.

Example

The following example illustrates how the call object can be used to invoke a remote method synchronously, using a call object, as seen in the doAdd function. The doSubtraction function uses asynchronous communication.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<LINK REL="stylesheet" HREF="/workshop/samples/samples.css" TYPE="text/css">

<SCRIPT language="JavaScript">
var iCallID;
var callObj;
function init()
{
	
	// Establish the friendly name "MyMath" for the WebServiceURL
    service.useService("..\\..\\MathService.asmx?WSDL","MyMath");
	// Disable the button that calls the method which uses synchronous
	// communication. The button is enabled in a function called by the
	// onserviceavailable event.
	doAddButton.disabled = true;
	service.onserviceavailable = enableButton();
}
function enableButton(){
doAddButton.disabled = false;
}

function doAdd(x, y){
	// Synchronous communication
	// Create the SOAPHeader object
	var headObj = new Object();
	// Create the call object 
	callObj = service.createCallOptions();
	callObj.async = false;
	callObj.params = new Array();
	callObj.params.a = x;
	callObj.params.b = y;
	callObj.funcName = "Add";
	callObj.SOAPHeader = new Array();
	callObj.SOAPHeader[0] = headObj;
    oSPAN.innerText = x + " + " + y + " = ";
    // The following uses a callback handler named "mathResults"
	iCallID = service.MyMath.callService(mathResults, callObj);
	mathResults(iCallID);
}


function doSubtraction(y, x){
	// Asynchronous communication (the default)
    oSPAN.innerText = y + " - " + x + " = ";
    // Call the WebMethod in Math.asmx subtract.
    // The following example uses a callback handler named "mathResults"
    iCallID = service.MyMath.callService(mathResults,  "Subtract", y, x);
}


function mathResults(result){
    // If there is an error, and the call came from the call() in init()
    if(result.error){
    // Pull the error information from the event.result.errorDetail properties
        var xfaultcode   = result.errorDetail.code;
        var xfaultstring = result.errorDetail.string;
        var xfaultsoap   = result.errorDetail.raw;
		oSPAN.innerText = xfaultcode + " " + xfaultstring + " " + xfaultsoap;
    }// If there was no error
    else{
        // Show the arithmetic
          oSPAN.innerText += result.value;     
    }
}
</SCRIPT>
</HEAD>
<body onload="init()">
<div id="service" style="behavior:url(../webservice.htc)"></div>
<BR><BR>
Equation : <SPAN id="oSPAN"></SPAN>
<BR><BR>
<BUTTON id="doAddButton" onclick="doAdd(5, 6);">Do Add function of 5 and 6</BUTTON>
<BUTTON onclick="doSubtraction(6, 5);">Do Subtraction of 6 and 5</BUTTON>
</body>

Applies To

WebService

See Also

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.