【发布时间】:2017-07-26 08:01:28
【问题描述】:
调用soap 服务会引发404 错误,但在SOAP UI 中可以正常工作。我发现这可能是由于 CORS 问题,所以我将标题设置为 'Access-Control-Allow-Origin': '*' 但没有运气
以下是我如何调用服务
let _this=this;
var webServiceURL = 'http://localhost:8082/ode/processes/WS_Invocation.WS_InvocationPort';
var soapMessage = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.invocation.tps"><soapenv:Header/><soapenv:Body><ws:WS_InvocationRequest><ws:input>1</ws:input><ws:input1>Mohan</ws:input1></ws:WS_InvocationRequest></soapenv:Body></soapenv:Envelope>'
$.ajax({
url: _this.webServiceURL,
type: "POST",
dataType: "xml",
crossDomain: true,
headers: {
'Access-Control-Allow-Origin': '*'
},
data: _this.soapMessage,
contentType: "text/xml; charset=\"utf-8\"",
success: _this.OnSuccess,
error: _this.OnError
});
【问题讨论】:
-
从您的
$.ajax呼叫中删除headers: { 'Access-Control-Allow-Origin': '*' }。 Access-Control-Allow-Origin 是服务器必须发送的 response 标头。将其作为请求标头发送不会为您解决任何问题。删除后,要获得更多帮助,请使用 stackoverflow.com/posts/45309437/edit 编辑/更新您的问题,并添加您在浏览器开发工具控制台中看到的确切错误消息。