Closed tilmanginzel closed 8 years ago
As far as I can tell, looking at your request and response (thanx for that, big help!) and the code for $.soap you get an error from the underlying $.ajax call...
To explain a little about what is going on, so you can do some coding and testing:
In $.soap line# 265:
return $.ajax({
// options....
dataType: "xml",
// more options....
you see the actual $.ajax call which has no error
or success
function, instead it returns the jqXHR object back to line# 121:
return soapEnvelope.send({
// options....
}).done(function(data, textStatus, jqXHR) {
// deal with response when succesful
}).fail(function(jqXHR, textStatus, jqXHR) {
// deal with an error....
});
So my guess is the $.ajax function wants to parse the response, because we said it would be dataType: "xml"
but the parser fails. So to fix this you might want to try and outcomment line# 273:
dataType: "xml",
If that doesn't change things it might be worthwhile to look into using the browsers native XMLHttpRequest and skip using $.ajax (and thus $.soap) in your particular situation.
I hope you find this useful, please let me know your findings; if it just takes a tweak to improve $.soap overall I am always interested!
Thanks for your fast response! Outcommenting line 273 didn't help, but setting dataType: "text"
did. Now the success
callback is invoked and I get a SOAPResponse with its content as plain text.
I was able to extract the <soap:Envelope>
with a regex and replace the content of the SOAPResponse afterwards.
success: function(SOAPResponse) {
var regex = "<soap:Envelope.*soap:Envelope>";
var content = SOAPResponse.content.match(regex)[0];
SOAPResponse.content = content;
console.log(SOAPResponse.toXML());
},
Now I am getting a well-formed XML structure which can be used for further parsing or whatever I want. Seems a little bit hacky but I guess its the best workaround I can find. Maybe I will dig into the native XMLHttpRequest some time, but right now this should do it.
happy to hear you're okay!
Hey guys, I am having trouble to read the
<soap:Envelope>
from the response I am receiving. I am using jquery.soap.js version 1.6.7 and jquery version 1.11.3.First of all, here is my
$.soap
call.The corresponding raw HTTP request:
And this is the response:
So the problem is that the
<soap:Envelope>
ist wrapped inside a multipart message. This results in aparseerror
and theerror
callback is invoked. Is there anything I am missing? Or is it simply not possible to read multipart messages? Unfortunately this is something I cannot fix on the server side.An acceptable workaround could be to extract the envelope by hand, e.g. with a regex. Is there a possibility to manipulate the response before the
error
callback is invoked? Any help is appreciated. Thanks!