45fan.com - 路饭网

搜索: 您的位置主页 > 电脑频道 > 电脑教程 > 阅读资讯:调用Web Service的客户端javascript的方法

调用Web Service的客户端javascript的方法

2016-09-03 16:52:15 来源:www.45fan.com 【

调用Web Service的客户端javascript的方法

<html>
<head>
<script language="JavaScript">
var iCallID;
var service_MsgXML = new ActiveXObject("MSXML.DOMDocument");
function init()
{
service.useService("http://gengw/jyjd/service/service.asmx?WSDL","service");
iCallID = service.service.callService("GetUserList",7);
}


</script>
</head>
<body onload="init()">
<div id="service" style="behavior:url(http://gengw/chat/webservice.htc)" onresult="onWSresult()">
</div>
<SCRIPT language="JavaScript1.2">
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;
alert(xfaultstring);
}
else
{
var xmlResult = event.result.raw.xml;
// var result = event.result.value;
// alert(result);
if (xmlResult != "" && xmlResult != null)
{

service_MsgXML.loadXML(xmlResult);
maxNum = service_MsgXML.getElementsByTagName("msgcontent").length
column=service_MsgXML.getElementsByTagName("msgcontent").item(0).childNodes
alert(maxNum);
service_ChatMsgs.innerHTML = "";
for (m=0;m<=maxNum-1;m++){
//for(x in service_MsgXML.documentElement.childNodes)
//alert("The method returned the result : " + xmlResult);
//service_ChatList.innerText = service_MsgXML.selectSingleNode("//msgtime").text;
//service_ChatList.scrollTop = 2000;
// mName=column.item(m).tagName;
service_ChatMsgs.innerHTML += service_MsgXML.getElementsByTagName("msgtime").item(m).text+":<br>";
service_ChatMsgs.innerHTML += service_MsgXML.getElementsByTagName("msgcontent").item(m).text+"<br>";
//service_ChatMsgs.innerHTML += "<br>";
//service_ChatMsgs.innerHTML += service_MsgXML.selectSingleNode("//msgcontent").text;
//service_ChatMsgs.scrollTop = 2000;
}
}
window.setTimeout('iCallID = service.service.callService("GetUserList",7);',3000);
}
}
</script>
<Div id="service_ChatMsgs" style="Height:100%;Width:100%;Overflow:Auto;"></Div>
</body>
</html>

 

 

本文地址:http://www.45fan.com/dnjc/71822.html
Tags: 客户端 Web service
编辑:路饭网
关于我们 | 联系我们 | 友情链接 | 网站地图 | Sitemap | App | 返回顶部