调用第三方接口,对方接口为内网地址,并且与我方服务器不通,所以需要在js调用对方提供的webservice接口
function RequestWebService() {
var data;
data = '<soapenv:Envelope xmlns:xsi="http://www.w3.org/XMLSchema-instance" xmlns:xsd="http://www.w3.org/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/envelope/" xmlns:prox="http://proxy.sun.com"><soapenv:Header/><soapenv:Body><prox:acceptMessage soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><in0 xsi:type="xsd:string"><![CDATA[<Request><Header><sender>HIS</sender><receiver>PLAT</receiver><sendTime>20170120173325</sendTime><msgType>TCM_HIS_01</msgType><outpatientNo>320903|18860826500</outpatientNo><orgCode>320903</orgCode></Patient></Request> ]]></in0></prox:acceptMessage></soapenv:Body></soapenv:Envelope>';
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var URL = "http://esb.sinosoft.com.cn/services/HIS?wsdl";
xmlhttp.Open("POST", URL, false);
xmlhttp.SetRequestHeader("Content-Type", "text/xml; charset=utf-8"); //SOAP 1.1为text/xml ; 1.2为 application/soap+xml
xmlhttp.SetRequestHeader("SOAPAction", "http://engine.transfer.com/acceptMessage"); //设置SOAPAction
xmlhttp.Send(data);
var text = xmlhttp.responseText;
console.log(text); //返回结果
}
data为在soap-ui中请求接口的xml文本,直接复制过来就可以;
xmlhttp.SetRequestHeader("SOAPAction", "http://engine.transfer.com/acceptMessage"); //设置SOAPAction