調用soap服務會拋出404錯誤,但在SOAP UI中正常工作。某處我發現這可能是由於CORS問題,所以我設置標題爲「訪問控制允許來源」:「*」,但沒有運氣SOAP服務通過AJAX調用失敗,但在SOAPUI中正常工作
下面是我如何調用服務
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是服務器必須發送的*響應*標頭。將它作爲請求標題發送不會爲您解決任何問題。刪除之後,要獲得更多幫助,請使用https://stackoverflow.com/posts/45309437/edit來編輯/更新您的問題,並在瀏覽器devtools控制檯中添加您看到的確切錯誤消息。 – sideshowbarker