저는이 Ajax SOAP 요청이 작동하지 않는 이유를 알 수 없습니다.SOAP와 Ajax가 함께 작동하지 않습니다.
이 대부분 코드의 나의 버전은 여기에서 발견된다 : jQuery AJAX SOAP based web services and CORS (cross origin resource sharing)
기능이 콘솔에서 500 오류를 반환 실행됩니다. 이 오류는 다음 오류가 포함 된 XML을 반환합니다.
<faultstring>Unable to handle request without a valid action parameter. Please supply a valid soap action.</faultstring>
아무 것도 서버 오류 로그에 표시되지 않습니다. 해당 요청을 생성하는 데 사용하는 XML은 SOAP UI에 의해 작성되었으며 해당 컨텍스트에서 오류없이 올바른 정보를 리턴합니다.
추가 정보 : 서버 헤더가 올바르게 설정되었으며 도메인 간 문제없이 전체 XML 서비스를 반환 할 수 있습니다. 문제가있는 "se"변수가 나타내는 쿼리를 보내려고 할 때만입니다. 나는이 코드를 '? WSDL'이 존재하고 결석 한 것으로 시도했다. 나는 POST와 GET을 사용하여 시도했다.
<script type="text/javascript">
var se = '';
se += '<?xml version="1.0" encoding="UTF-8" standalone="no"?>';
se += '<soapenv:Envelope xmlns:soapenv="schemas.xmlsoap.org/soap/envelope/" xmlns:test="http://XXX.YYYY.com/">';
se += '<soapenv:Header/>';
se += '<soapenv:Body>';
se += '<test:GetCurrentProductRelease/>';
se += '</soapenv:Body>';
se += '</soapenv:Envelope>';
$.ajax({
url: 'http://xx.xx.xxx.xxxx/XXXAdminDS/XXXAdminDS.asmx?WSDL',
type: "POST",
dataType: "xml",
data: se,
crossDomain: true,
headers: {"X-Requested-With": "XMLHttpRequest"},
beforeSend: function(xhr) {
xhr.setRequestHeader("SOAPAction", "http://xx.xx.xxx.xxx/XXXAdminDS/XXXAdminDS.asmx?WSDL");
},
// success: function(xml) {
// some code here
// },
// failure: function(xml) {
// more code here
// },
contentType: "charset=UTF-8"
});
}
</script>