I have to make SOAP calls from javascript between different domains. On the server side there is a list of allowed domains, methods and headers which are included in the response by a filter. It works well (even between different domains) when the response code is 200 but when an exception is thrown on the server side the xhr object has 0 status instead of 500 and the responseText is empty. When using on the same domain the status and the responseText is ok.
The relevant code is as follows:
function onError(xhr, status, thrownError) {
alert(xhr.status);
alert(xhr.responseText);
}
$.ajax({
type: "POST",
url: SOAPClient.Proxy,
dataType: "xml",
processData: false,
data: content,
context: context,
contentType : SOAPClient.ContentType + "; " + SOAPClient.CharSet,
error: onError,
success: onSuccess,
complete: onComplete,
beforeSend: function(req) {
req.setRequestHeader("Method", "POST");
req.setRequestHeader("Content-Length", SOAPClient.ContentLength);
req.setRequestHeader("SOAPServer", SOAPClient.SOAPServer);
req.setRequestHeader("SOAPAction", soapReq.Action);
}
});
I'm using jQuery-1.4.2. The allowed headers are "SOAPServer", "SOAPAction" and "Method". I tried it in FF 3.6.10 and Google Chrome 7.0.517.36