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 οnlοad="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);
  // Add code to output error information here
 }
 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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值