js调用webservice 摘录

function ImportDataFun(){
var Trans_Index=document.getElementById("Trans_Index").value;
var PN=document.getElementById("PN").value;
var ZH_Lot=document.getElementById("ZH_Lot").value;
if(Trans_Index==""){
alert("请选择导入数据对应关系!");
return;
}else if(PN.trim()==""){
alert("PN不能为空!");
document.getElementById("PN").value="";
document.getElementById("PN").focus();
return;
}else if(ZH_Lot.trim()==""){
alert("珠海盒号不能为空!");
document.getElementById("ZH_Lot").value="";
document.getElementById("ZH_Lot").focus();
return;
}

//下面调用web services
var UserID=document.getElementById("UserID").value;
var SQLofShanghaiData=document.getElementById("ExeclSQL").value;

var xmlHttp=CreateHTTPObject();
xmlHttp.onreadystatechange=function() {
if (xmlHttp.readyState == 0)
{
document.getElementById("divMessage").innerHTML = "尚未初始化";
}
else if (xmlHttp.readyState == 1)
{
document.getElementById("divMessage").innerHTML = "正在加载";
}
else if (xmlHttp.readyState == 2)
{
document.getElementById("divMessage").innerHTML = "加载完毕";
}
else if (xmlHttp.readyState == 3)
{
document.getElementById("divMessage").innerHTML = "正在处理";
}
else if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
//在这里写返回调用代码
//document.getElementById("response").innerHTML = xmlHttp.responseText;
var xmlDOM = xmlHttp.responseXML;
Rowes = xmlDOM.getElementsByTagName("TransSH_DataToZHResponse");
var RecordCount = Rowes.length;
if(RecordCount>0){
var strMessage = Rowes[0].childNodes[0].text;

if(strMessage.length<4){
document.getElementById("divMessage").innerHTML = "处理完成,共导入【"+strMessage+"】条测试数据。";
alert("处理完成,共导入【"+strMessage+"】条测试数据。");
}else{
document.getElementById("divMessage").innerHTML = "处理完成,处理过程中发生错误:{"+strMessage+"}。";
alert("处理完成,处理过程中发生错误:{"+strMessage+"}。");
}
}
}
}
}//end xmlHttp.onreadystatechange=function()

var xml = ‘<?xml version="1.0" encoding="utf-8"?> ‘ +
‘<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ‘ +
‘ xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">‘ +
‘<soap:Body> ‘ +
‘<TransSH_DataToZH xmlns="http://Filter.system.oplink.com.cn/"> ‘ +
‘<strGID>‘ + escape(Trans_Index) + ‘</strGID> ‘ +
‘<SQLofShanghaiData>‘ + SQLofShanghaiData + ‘</SQLofShanghaiData> ‘ +
‘<PN>‘ + PN + ‘</PN> ‘ +
‘<Zh_lot>‘ + escape(ZH_Lot) + ‘</Zh_lot> ‘ +
‘<UserID>‘ + UserID + ‘</UserID> ‘ +
‘</TransSH_DataToZH> ‘ +
‘</soap:Body> ‘ +
‘</soap:Envelope>‘;
document.getElementById("divMessage2").innerHTML=xml;
var WebService_URL = document.getElementById("Url_ZH").value;
WebService_URL = WebService_URL.slice(0, WebService_URL.length - 1) + "?op=TransSH_DataToZH";
//alert(WebService_URL);
xmlHttp.open("POST", WebService_URL, true);
xmlHttp.setRequestHeader("Content-Type", "text/xml;charset=utf-8");
xmlHttp.SetRequestHeader("Content-Length", xml.length);
xmlHttp.setRequestHeader("SOAPAction", "http://Filter.system.oplink.com.cn/TransSH_DataToZH");
xmlHttp.send(xml);
}

js调用webservice 摘录

上一篇:通过JS判断浏览器类型


下一篇:threejs报错:setRotationFromEuler is not a function