I'm using the soap service for AngularJS from Andrew McGivery
It works perfectly when called from Chrome but it returns a typeError on Firefox and IE11.
TypeError: e is null at angular.soap.js line 16
The code in question is as follows:
.factory("$soap",['$q',function($q){
return {
post: function(url, action, params){
var deferred = $q.defer();
//Create SOAPClientParameters
var soapParams = new SOAPClientParameters();
for(var param in params){
soapParams.add(param, params[param]);
}
var soapCallback = function(e){
//ERROR THROWN ON LINE BELOW
if(e.constructor.toString().indexOf("function Error()") != -1){
deferred.reject("An error has occurred.");
} else {
deferred.resolve(e);
}
}
SOAPClient.invoke(url, action, soapParams, true, soapCallback);
return deferred.promise;
},
setCredentials: function(username, password){
SOAPClient.username = username;
SOAPClient.password = password;
}
}
}]);
e in Chrome is the object returned by my webservice (user object), in Firefox it's null and I don't know where to look in the library to debug the problem.
UPDATE:
My controller looks like this:
.controller('SoapCtrl', function($soap) {
this.login = function(credentials) {
$soap.post('MYAPI', 'MYMETHOD', {login: credentials.login, password: credentials.password}).then(function(data) {
console.log(data.userid);
});
}
})
I also tried calling the same webservice from the jquery plugin jquery.soap inside my angular application and I get the expected behaviour in both Chrome and Firefox.
LAST UPDATE
Since this is a professional project, we decided to move on to a plugin that works. jquery.soap
2 issues have been posted on the author's page with no answer for the moment.
I would have awarded the bounty to a valid answer but half the bounty is going automatically to the answer with 2 upvotes...
On the library, check the file soapclient.js, on the line 195
SOAPClient._onSendSoapRequest = function(method, async, callback, wsdl, req)
{
var o = null;
var nd = SOAPClient._getElementsByTagName(req.responseXML, method + "Result");
if(nd.length == 0)
nd = SOAPClient._getElementsByTagName(req.responseXML, "return"); // PHP web Service?
if(nd.length == 0)
{
if(req.responseXML.getElementsByTagName("faultcode").length > 0)
{
if(async || callback)
o = new Error(500, req.responseXML.getElementsByTagName("faultstring")[0].childNodes[0].nodeValue);
else
throw new Error(500, req.responseXML.getElementsByTagName("faultstring")[0].childNodes[0].nodeValue);
}
}
else
o = SOAPClient._soapresult2object(nd[0], wsdl);
if(callback)
callback(o, req.responseXML);
if(!async)
return o;
}
if you say that in firefox the e
value it's null
it's because in this method the o
variable never it's set. Debug this method will be a help.
in the function SOAPClient._getElementsByTagName
I change the linereturn document.getElementsByTagName(tagName);
Forreturn document.getElementsByTagNameNS("*", tagName);
work for me!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With