Export (0) Print
Expand All

WebService Behavior

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

Attaches a WebService behavior to a document.

Syntax

XML <Prefix: CustomTag ID=sID STYLE="behavior:url('webservice.htc')" />
HTML <ELEMENT STYLE="behavior:url('webservice.htc')" ID=sID>
Scripting object .style.behavior = "url('webservice.htc')"
object .addBehavior ("webservice.htc")

Possible Values

Prefix Prefix that associates the CustomTag with an XML namespace. This prefix is set using the XMLNS attribute of the HTML tag.
CustomTag User-defined tag.
sID String that specifies a unique identifier for the object.

Members Table

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

Attributes/Properties
Property Description
async Specifies the mode of remote method invocation.
code A machine-readable error code that corresponds to a specific invocation of the callService method.
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.
error A Boolean property created by the WebService behavior after calling the callService method.
funcName Specifies the name of a remote function exposed by a Web Service.
id A property of the result object that has a unique value which corresponds to a specific execution of the callService method.
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.
raw Exposes the raw SOAP data packet returned by the Web Service after invoking the callService method.
reuseConnection Specifies the persistence of the connection information required by Web services that use Secure Sockets Layer (SSL) authentication.
serviceAvailable Indicates whether the WSDL information was returned successfully from an invocation of the useService method.
serviceUrl Specifies the URL of a Web Service.
SOAPHeader An Array of SOAP headers that overrides the default SOAP header generated by the WebService behavior.
string A human-readable error message that corresponds to a specific invocation of the callService method.
timeout Not supported.
userName Specifies a user name for Web Services that require user authentication.
userName Retrieves the sFriendlyName parameter that is passed to the useService method.
value A property of the result object that is created at run time.
WSDL The WSDL returned by a Web Service after an invocation of the useService method.
Events
Event Property Description
onresult Fires when a result has been received from a remote method callService using the WebService behavior.
onserviceavailable Fires after the WebService behavior has attempted to obtain the WSDL from a Web Service.
Methods
Method Description
callService Calls a method that is implemented on a Web Service.
createCallOptions Creates an instance of call object that can be passed as a parameter to the callService method.
createUseOptions Creates a useOptions object that can be passed as a parameter to the useService method.
useService Establishes a friendly name for a Web Service URL that can be referenced from script.
Objects
Object Description
call A script object that can be passed as a parameter to the callService method.
result This object exposes the results and brief diagnostics for an invocation of the callService method.
useOptions An object that can be passed as a parameter to the useService method.

Remarks

The WebService behavior enables methods that are implemented on Web Services to be called from client-side script from a document .

To attach a WebService behavior to a document , first download the WebService HTC File file and put a copy in the same directory as the document that use s the behavior.

The WebService behavior is available with Microsoft Internet Explorer 5 and later versions.

Example

The following sample shows how the WebService behavior can be attached to a document. The behavior is used to call a simple arithmetic function named add from a Web Service. See Using the WebService Behavior for a detailed explanation of the following code.


<html>
<head>
<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;
		
		// Add code to output error information here
	}
	else
	{
		alert("The method returned the result : " + event.result.value);
	}
}
</script>
</head>
<body onload="init()">
<div id="service" style="behavior:url(webservice.htc)" onresult="onWSresult()">
</div>
</body>
</html>

See Also

Community Additions

ADD
Show:
© 2014 Microsoft