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 nameA 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 Web page using the WebService behavior. In this case, the ?WSDL query string is assumed by the behavior.WSDL file nameA Web Services Description Language (WSDL) file name. The WSDL file must have a .wsdl file extension.Full file pathThe 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 pathA 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.
Web Service file name
.asmx
?WSDL
WSDL file name
.wsdl
Full file path
Relative path
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.
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 Web page. 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 Web page. 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 Web page. 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 Web page. service.useService("./wsfld/myws.asmx?WSDL","MyMath");
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 Web page.
math.asmx
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 Web page.
conversion.wsdl
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.
myws.asmx
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 Web page.
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 Web page.
service.useService("./wsfld/myws.asmx?WSDL","MyMath");
Applies To
WebService
See Also
callService, HTC Reference, Using HTML Components to Implement DHTML Behaviors in Script, onresult, Using DHTML Behaviors, Using the WebService Behavior, About the WebService Behavior
I am using same code to call a .net web service from my JavaScript, it was working fin i IE6, after updating to IE7 getting an JavaScript error message "Object doesn’t support this method or property". any help is greatly appreciated.
Thanks much,Sam.