Export (0) Print
Expand All

useService Method

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

Establishes a friendly name for a Web Service URL that can be referenced from script.

Syntax

sElementID.useService(sWebServiceURL, sFriendlyName [, oUseOptions])

Parameters

sElementID Required. The id of the element to which the WebService behavior is attached.
sWebServiceURL Required. A String specifying the URL of the Web Service, that uses one of the following path types. See the examples section that illustrates several variations of this parameter.
Web Service file name
A Web service file that has an .asmx file extension. This short form of the URL is sufficient if the Web service is located in the same folder as the document using the WebService behavior. In this case, the ?WSDL query string is assumed by the behavior.
WSDL file name
A Web Services Description Language (WSDL) file name. The WSDL file must have a .wsdl file extension.
Full file path
The full path to a WebService (.asmx) or WSDL (.wsdl) file. A file path to a Web Service must include the ?WSDL query string. Either a local file path or a URL can be specified.
Relative path
A relative path to a WebService (.asmx) or WSDL (.wsdl) file. A file path to a Web Service must include the ?WSDL query string.
sFriendlyName Required. A String representing a friendly name for the Web Service URL.
oUseOptions Optional. An instance of the useOptions object.

Return Value

No return value.

Remarks

After using this method, the identifier specified in sFriendlyName can be used in script as a reference to the Web Service specified by sWebServiceURL.

The useOptions object can be used when the Secure Sockets Layer (SSL) authentication must be retained for multiple remote method invocations. For code samples illustrating the use of this technique, see the createUseOptions method.

Examples

The following sample defines the friendly name MyMath from the URL specified in the sWebServiceURL parameter.


<script language="JavaScript">
function init()
{
    service.useService("math.asmx?WSDL","MyMath");
}
</script>
<body onload="init()">
<div id="service" style="behavior:url(webservice.htc)">
</div>
</body>

The following examples illustrate some valid forms of the sWebServiceURL parameter.

The following code snippet illustrates the short form of sWebServiceURL. In this case, the math.asmx file must be located in the same folder as the document.


service.useService("math.asmx","MyMath");

The following code snippet illustrates how a WSDL file can be specified for the sWebServiceURL parameter. In this case, the conversion.wsdl file must be located in the same folder as the document.


service.useService("conversion.wsdl","MyConverter");

The following code snippet defines the sWebServiceURL parameter as a local file. In this case, the ?WSDL query string must be included.


service.useService("C:\inetpub\wwwroot\myproject\myws.asmx?WSDL","MyMath");

The following code snippet defines the sWebServiceURL parameter as the full HTTP file path to the myws.asmx Web service file. In this case, the ?WSDL query string must be included.


service.useService("http://localhost/myproject/myws.asmx?WSDL","MyMath");

The following code snippet defines the sWebServiceURL parameter as a relative file path to the myws.asmx Web service file. In this case, the ?WSDL query string must be included. This example points to a Web Service file two levels up from the document.


service.useService("../../myws.asmx?WSDL","MyMath");

The following code snippet defines the sWebServiceURL parameter as a relative file path to the myws.asmx Web service file. In this case, the ?WSDL query string must be included. The path points to the myws.asmx Web Service, which is located in the wsfld subfolder of the document.


service.useService("./wsfld/myws.asmx?WSDL","MyMath");

Applies To

WebService

See Also

Community Additions

ADD
Show:
© 2014 Microsoft