forked from andrewmcgivery/angular-soap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangular.soap.js
More file actions
32 lines (27 loc) · 773 Bytes
/
angular.soap.js
File metadata and controls
32 lines (27 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
angular.module('angularSoap', [])
.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]);
}
//Create Callback
var soapCallback = function(e){
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;
}
}
}]);