While attempting to send a request and include a SOAP object, I encountered an issue where the responseXML was not being returned even though the request was successful. After testing with Fiddler and HTTP Client, both of which returned the correct responses, it became clear that the problem lied within Prototype.
I tested putting the information in both the header and parameters fields...
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript">
function test(){
var body = '<?xml version="1.0" encoding="utf-8"?>' +
'<soap:Envelope' +
' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' +
' xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"' +
' xmlns:tns="urn:uvindexalert" xmlns:types="urn:uvindexalert/encodedTypes"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
' xmlns:xsd="http://www.w3.org/2001/XMLSchema">' +
' <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' +
' <tns:getUVIndexAlertByZipCode>' +
' <in0 xsi:type="xsd:string">92109</in0>' +
' </tns:getUVIndexAlertByZipCode>' +
' </soap:Body>' +
'</soap:Envelope>';
var headers = ["SOAPAction", " ", "Content-Type", "text/xml"];
var request = new Ajax.Request("http://iaspub.epa.gov/uvindexalert/services/UVIndexAlertPort?wsdl", {
contentType: "application/xml",
requestHeaders: headers,
parameters: "SOAPAction: ",
postBody: body,
onSuccess: function(response){
var j = 0;
},
onFailure: function(){
var i = 0;
}
});
}
test();
</script>
The variables i & j are included for debugging purposes. I also researched online and found a suggestion to switch from `text/xml` to `application/xml` along with adding `charset=utf-8`, however, this did not solve the issue. Does anyone have a definite solution for retrieving XML with a SOAPAction?