I've got a jQuery SOAP request which for some reason does not work. What bothers me is that I've considered everything necessary for a CORS request, but all it returns is status 0 with the statusText "Error".
I know this is probably an unproductive (and dumb) question, but may you please take a look and find what I couldn't? I'd be really glad since this is exasperating me for days now. The code is a complete HTML file with JS already and can be taken as-is, only the jQuery path has to be adjusted.
Kind 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>
Analysing the response via Firebug, there's some weird 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: non-matching tag. Expected , line 71, column 96". Is that a serverside error? Because it cannot come from my minified HTML fiel as it does not have a table.
Kind regards, jaySon