
怎么用JavaScript调用SOAP接口
2个回答
2015-08-07 · 知道合伙人数码行家
关注

展开全部
标签的src属性可以调取webservice上的js文件。
标签内的js代码,可以通过对应html标签的属性(例如image的src属性),来调取webservice上的对应文件。
也可以通过xmlHttpRequest对象来请求webservice上的脚本文件(如php),来使用返回此脚本文件返回的结果。
标签内的js代码,可以通过对应html标签的属性(例如image的src属性),来调取webservice上的对应文件。
也可以通过xmlHttpRequest对象来请求webservice上的脚本文件(如php),来使用返回此脚本文件返回的结果。
展开全部
自己琢磨了一下解决了:
var data='<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservice.gt3k.huawei.com">';
data=data+'<soapenv:Header>';
data=data+'<Username xsi:type="xsd:string" xs:type="type:string" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance">GT3000System</Username>';
data=data+'<Password xsi:type="xsd:string" xs:type="type:string" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance"></Password>';
data=data+'</soapenv:Header>';
data=data+'<soapenv:Body>';
data=data+'<web:getEntity soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">';
data=data+'<path xsi:type="xsd:string" xs:type="type:string" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance">resource_root</path>';
data=data+'<depth xsi:type="xsd:int" xs:type="type:int" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance">1</depth>';
data=data+'<params xsi:type="xsd:string" xs:type="type:string" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance"/>';
data=data+'</web:getEntity>';
data=data+'</soapenv:Body>';
data=data+'</soapenv:Envelope>';
var url="http://10.78.191.86:8082/GT3KServer/services/TestManagementService?wsdl";
var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("post",url,false);
// xmlhttp.SetRequestHeader("Accept-Encoding","gzip","deflate");
xmlhttp.SetRequestHeader ("Content-Type","text/xml; charset=utf-8");
//xmlhttp.SetRequestHeader("User-Agent","Jakarta Commons-HttpClient/3.1");
xmlhttp.SetRequestHeader ("Content-Length",data.length);
xmlhttp.SetRequestHeader ("host","10.78.191.86:8082");
xmlhttp.SetRequestHeader ("SOAPAction","getEntity");
xmlhttp.send(data);
var x = xmlhttp.responseXML;
var data='<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservice.gt3k.huawei.com">';
data=data+'<soapenv:Header>';
data=data+'<Username xsi:type="xsd:string" xs:type="type:string" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance">GT3000System</Username>';
data=data+'<Password xsi:type="xsd:string" xs:type="type:string" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance"></Password>';
data=data+'</soapenv:Header>';
data=data+'<soapenv:Body>';
data=data+'<web:getEntity soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">';
data=data+'<path xsi:type="xsd:string" xs:type="type:string" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance">resource_root</path>';
data=data+'<depth xsi:type="xsd:int" xs:type="type:int" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance">1</depth>';
data=data+'<params xsi:type="xsd:string" xs:type="type:string" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance"/>';
data=data+'</web:getEntity>';
data=data+'</soapenv:Body>';
data=data+'</soapenv:Envelope>';
var url="http://10.78.191.86:8082/GT3KServer/services/TestManagementService?wsdl";
var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("post",url,false);
// xmlhttp.SetRequestHeader("Accept-Encoding","gzip","deflate");
xmlhttp.SetRequestHeader ("Content-Type","text/xml; charset=utf-8");
//xmlhttp.SetRequestHeader("User-Agent","Jakarta Commons-HttpClient/3.1");
xmlhttp.SetRequestHeader ("Content-Length",data.length);
xmlhttp.SetRequestHeader ("host","10.78.191.86:8082");
xmlhttp.SetRequestHeader ("SOAPAction","getEntity");
xmlhttp.send(data);
var x = xmlhttp.responseXML;
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询