来自Angular 6的SOAP API调用的空响应

时间:2019-02-24 21:03:47

标签: javascript angular soap angular6

我正在拨打一个简单的Soap电话并尝试处理该请求。这是我的角度6分量:

callSoap() {
const xmlhttp = new XMLHttpRequest();
xmlhttp.open('POST', 'https://soapAPIURL.net/', true);
const sr =
    `<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://soapAPIURL.net/ws" xmlns:com="http://soapAPIURL.com/common" xmlns:req="http://soapAPIURL.net/request">
      <soapenv:Header/>
        <soapenv:Body>
          <ws:CreateUser>
            <com:Header>
              <com:User>1234</com:User>
            </com:Header>
              <req:Name>Test Name</req:Name>
          </ws:CreateUser>
          </soapenv:Body>
      </soapenv:Envelope>`;

}

xmlhttp.setRequestHeader("SOAPAction", "http://soapAPIURL/CreateUser");
xmlhttp.setRequestHeader('Content-Type', 'text/xml');
xmlhttp.responseType = 'document';    

xmlhttp.onreadystatechange =  () => {
  console.log(xmlhttp);
    if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
            const xml = xmlhttp.responseXML;
            console.log(xml);
            console.log('Ok 200');
        }
    }
}

// Send the POST request.
xmlhttp.send(sr);

第一个console.log打印出xmlhttp请求:

responseText: "", 
responseType: "",
status: 200,
responseXML: NULL,
response URL: (which I don't think is correct, its the same as my xmlhttp.open URL, my response Type is ''.

我也收到了CORBS(跨源读取阻止(CORB)阻止跨源响应错误)。

我正确处理了响应吗? 不确定是服务器端问题还是客户端问题?可能是我从我的角度组件中调用此SOAP Api吗?

任何方向都很好。

0 个答案:

没有答案