js调用webservice接口并解决no soap Action Header问题

背景

调用第三方接口,对方接口为内网地址,并且与我方服务器不通,所以需要在js调用对方提供的webservice接口

调用方法

function RequestWebService() {
    var data;
    data = '
HISPLAT20170120173325TCM_HIS_01320903|18860826500320903 ]]>'; 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文本,直接复制过来就可以;

no soap action header问题解决办法

xmlhttp.SetRequestHeader("SOAPAction", "http://engine.transfer.com/acceptMessage"); //设置SOAPAction
 

 

 

你可能感兴趣的:(js)