我在发送SOAP请求时遇到内部服务器错误500

时间:2018-07-11 06:18:50

标签: javascript html5 web-services soap

我收到此错误“ POST: http://www.thomas-bayer.com/axis2/services/BLZService?wsdl 500(内部服务器错误)”,尝试使用Java脚本和HTML5发送SOAP请求。我在chrome控制台中看到此错误。我已经安装了CORS插件(以删除Allow-control-Allow-origin错误)并添加了代码行以消除CORS问题。

此WSDL在soap UI中运行良好,并且给出了正确的响应。

screenshot of the error,click here

<!DOCTYPE html>

<html>
<head>

    <script >
        function soapReq()
		{
		
  console.log("Hi");
  var str = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-  envelope" xmlns:blz="http://thomas-bayer.com/blz/">' 
   '<soap:Header>' +
     ' <httpProtocol> ' +
        '<customHeaders>' +
          '<add name="Access-Control-Allow-Origin" value="True" />' +
          '<add name="Access-Control-Allow-Headers" value="Content-Type" />' +
          '<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />' +
          ' </customHeaders>' +
      '</httpProtocol>' + 
	'</soap:Header>' +
   '<soap:Body>' +
      '<blz:getBank>' +
         '<blz:blz>66452776</blz:blz>' +
      '</blz:getBank>' +
    
   '</soap:Body>' +
'</soap:Envelope>' ;

        function createCORSRequest(method, url) {
		
		
  var xhr = new XMLHttpRequest();
  if ("withCredentials" in xhr) {
    
    xhr.open(method, url, true);
	
  } else if (typeof XDomainRequest != "undefined") {
    
    xhr = new XDomainRequest();
    xhr.open(method, url);
  } else {
   
    xhr = null;
  }
  return xhr;
}

// Helper method to parse the title tag from the response.
function getTitle(text) {
  return text.match('<title>(.*)?</title>');
}

// Make the actual CORS request.

  var url = 'http://www.thomas-bayer.com/axis2/services/BLZService';

  var xhr = createCORSRequest('POST', url);
  if (!xhr) {
    alert('CORS not supported');
    return;
  }

  // Response handlers.
  xhr.onload = function() {
    var text = xhr.responseText;
    var title = getTitle(text);
    alert('Response from CORS request to ' + url + ': ' + title);
	console.log(text);
  };

  xhr.onerror = function() {
    alert('Woops, there was an error making the request.');
  };
 xhr.setRequestHeader('Content-Type', 'text/xml');
  xhr.send(str);

}


 
           
    </script>
</head>
<body>

 <form>
    <input type="button" value="SOAP Request" onclick="soapReq();" />
 </form>
</body>

</html>

<add name="Access-Control-Allow-Origin" value="*" />
      <add name="Access-Control-Allow-Headers" value="Content-Type" />
      <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
   </customHeaders>
</httpProtocol>
 <form>
    <input type="button" value="SOAP Request" onclick="soapReq();" />
 </form>
</body>

</html>

0 个答案:

没有答案