Calling WebServices using Javascript

王朝asp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

If you are using Microsoft IE 5 or later, you can use the behavior/HTML-Component "WebService" to access a Web service. The "WebService" behavior communicates with Web services over HTTP using Simple Object Access Protocol (SOAP).

To use the "WebService" behavior, you must attach it to an element using the STYLE attribute, as follows:

<DIV ID="GiveItAName"

STYLE="behavior:url(webservice.htc)"></DIV>

A complete example taken from the Microsoft Web site is as follows:

<html>

<head>

<script language="JavaScript">

var iCallID;

function init()

{

service.useService

("http://myserver.com/services/myservice.asmx?WSDL",

"servicename");

}

function onmyresult()

{

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

alert("Error ");

}

else

{

service.innerHTML= "The method returned the result: "

+ event.result.value;

}

}

</script>

</HEAD>

<body onload="init();">

<BR>

Enter a Value <input type='text' id='param1'>

<BR>

<button onclick='iCallID = service.servicename.callService

("ProcedureName", param1.value);'>Call A Web Method</button>

<div id="service"

style="behavior:url(webservice.htc)"

onresult="onmyresult();">

</div>

</body>

</html>

source: http://weblogs.asp.net/Varad/archive/2004/06/14/155671.aspx

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航