For the life of me I cannot figure out why this Ajax SOAP request does not work.
This is mostly my version of the code found here: jQuery AJAX SOAP based web services and CORS (cross origin resource sharing)
When the function is run it returns a 500 error in the console. That error returns XML with the following error included:
<faultstring>Unable to handle request without a valid action parameter. Please supply a valid soap action.</faultstring>
Nothing shows up in the server error logs. The XML I'm using to generate that request was created by SOAP UI and returns the correct information without any error in that context.
Additional info: server headers have absolutely been set correctly and I can return the entire XML service with no cross-domain problems. It's only when I try to send in the query represented by the "se" variable that I have troubles. I have tried this code with '?WSDL' both present and absent. I've also tried using both POST and GET (although pretty sure POST is the one to use).
<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>