站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Javascript 专题Calling WebServices using Javascript

Calling WebServices using Javascript

摘要: Calling WebServices using Javascript
<textarea readonly style="border:none;font-family:Courier New;line-height:150%;width:760px;overflow-y:visible">

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:

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

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


<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();">


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



style="behavior:url(webservice.htc)"
onresult="onmyresult();">

</body>

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

</textarea>
↑返回目录
前一篇: javascript特效,左键菜单
后一篇: javascript自动弹出窗口代码