Why is jQuery domain rejected SOAP request rejected even though "CrossDomain" property is set?
I have a JQuery SOAP request that doesn't work for some reason. My concern is that I've covered everything required for a CORS request, but all it returns is status 0 with statusText "Error".
I know this is probably a non-productive (and dumb) question, but could you take a look and find what I couldn't? I would be very glad, because it has been annoying me for several days now. The code is a complete HTML file with JS already and can be taken as is, just adjust the jQuery path.
Regards, jaySon
<html>
<head>
<title>SOAP JavaScript Client Test</title>
<script type="text/javascript" src="jquery-2.1.1.min.js" ></script>
<script type="text/javascript" >
function fnc_soap() {
var request =
'<?xml version="1.0" encoding="utf-8"?> ' +
'<soap12:Envelope ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' +
'xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" ' +
'soap12:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> ' +
'<soap12:Body> ' +
'<CelsiusToFahrenheit xmlns="http://www.w3schools.com/webservices/"> ' +
'<Celsius>37</Celsius> ' +
'</CelsiusToFahrenheit> ' +
'</soap12:Body> ' +
'</soap12:Envelope>';
var url = "http://www.w3schools.com/webservices/tempconvert.asmx?op=CelsiusToFahrenheit";
jQuery.ajax({
type: "POST",
url: url,
data: request,
dataType: "xml",
crossDomain: true,
processData: true,
contentType: "text/xml; charset=\"utf-8\"",
xhrFields: {
withCredentials: true
},
beforeSend: function(xhr) {
// xhr.setRequestHeader('Access-Control-Allow-Methods', 'OPTIONS, TRACE, GET, HEAD, POST');
xhr.withCredentials = true;
},
headers: {
SOAPAction: "http://www.w3schools.com/webservices/CelsiusToFahrenheit"
},
success: function (msg) {
alert("Works!");
},
error: function (msg) {
alert("Failed: " + msg.status + ": " + msg.statusText);
}
});
}
</script>
</head>
<body>
<form name="Demo" action="" method="post">
<div>
<input type="button" value="Soap" onclick="fnc_soap();" ></input>
</div>
</form>
</body>
<html>
Parsing the response via Firebug, there is some strange error message in the XML part:
XML-Verarbeitungsfehler: Nicht รผbereinstimmendes Tag. Erwartet: </input>. Adresse: moz-nullprincipal:{e5ad2994-5e6d-4c61-9c47-7cad2f80f169} Zeile Nr. 71, Spalte 96:
...frmInput" type="text" size="50" name="Celsius"></td>
...-------------------------------------------------^
... which simply means "XML processing error: mismatched tag. Expected line 71, column 96". Is this a server bug? Because it can't come from my miniature HTML field as it doesn't have a table.
Regards, jaySon
source to share
No one has answered this question yet
See similar questions:
or similar: