1、 在<system.web></system.web>之间加下面一段
<webServices>
<protocols>
<add name="HttpSoap"/>
<add name="HttpPost"/>
<add name="HttpGet"/>
<add name="Documentation"/>
</protocols>
</webServices>
因为我的webservice是使用javascript 在页面调用,而且采用post方式通过httprequest调用webservice,所以
其实只需要<add name="HttpPost"/> 这个配置
2、
使用javascript 调用 webservice
var PNRList=new Array(<%=PNRArray %>);---c#代码中定义的string数组
var currentIndex=-1;
function StartCheckPNRStatus() --
{
if(PNRList.length!=0)
{
setTimeout(checkStatus,2000);--页面加载完毕后,2秒调用方法
//setInterval(checkStatus,2000);使用定时器
}
}
function checkStatus()
{
currentIndex++;
if(currentIndex==PNRList.length)
{
//clearInterval(timerHandle) 定时器,在前面定义个timerhandle
}
else
{
var httpRequest;
if(window.XMLHttpRequest)
{
httpRequest=new window.XMLHttpRequest();
}
else
{
httpRequest=new ActiveXObject("Microsoft.XMLHTTP");
}
httpRequest.onreadystatechange=function ()
{
if( httpRequest.readyState==4 )
{
if( httpRequest.status==200)
{
var xmlDom=httpRequest.responseXML.documentElement;
var PNRStatus=xmlDom.childNodes(0).text;--由于我返回的是字符串,所以可以这样取值
//alert(PNRStatus)
spanPNRStatus.innerText=PNRStatus;
if(PNRStatus!="RR")
{
/* spanLogBtn.style.display="";
spanCheckBtn.style.display="";
noRRCount++;
var spanNumOfTicket=document.getElementById("spanNumOfTicket"+PNRList[currentIndex]);//失败订单票数
var spanPriceDue=document.getElementById("spanPriceDue"+PNRList[currentIndex]);//失败订单金额
totalTicketNum+=parseInt(spanNumOfTicket.innerText);
totalPriceDue+=Number(spanPriceDue.innerText);
//给数据统计头赋值
var spanTotalOrderCount=document.getElementById("spanTotalOrderCount");
var spanRRCount=document.getElementById("spanRRCount");
var spanNoRRCount=document.getElementById("spanNoRRCount");
var spanTotalTicketNum=document.getElementById("spanTotalTicketNum");
var spanTotalPriceDue=document.getElementById("spanTotalPriceDue");
spanTotalOrderCount.innerText=PNRList.length;
spanRRCount.innerText=PNRList.length-noRRCount;
spanNoRRCount.innerText=noRRCount;
spanTotalTicketNum.innerText=totalTicketNum;
spanTotalPriceDue.innerText=totalPriceDue.toFixed(2); */ 这块是自定义
}
checkStatus();//当返回结果时,继续下一次取数组的值,继续调用webservice
}
}
}//end httpRequest.onreadystatechange
httpRequest.open("post", "IBEServiceGetPnrStatusByPNR.asmx/GetPNRStatusFromPNR", true);
httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
httpRequest.send("PNR="+PNRList[currentIndex]);
}
}
StartCheckPNRStatus();
</script>--在页面加载完毕后 执行这个调用webservice的方法
也可以使用定时器来定时调用webservice