Skip to content

Latest commit

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

angular-soap

An Angular port of a JavaScript SOAP Client into a factory that has a similar syntax to $http.

Usage

Before using the factory, you must import the two scripts and its module:

<scriptsrc="soapclient.js"></script><scriptsrc="angular.soap.js"></script>
angular.module('myApp',['angularSoap']);

Then, wherever you are going to consume it, make a reference to the $soap service for dependency injection:

.factory("testService",['$soap',function($soap){//use it here}])

$soap has one method, get, which accepts the following paramaters:

ParameterDescriptionExample
urlThe base URL of the service"http://www.cooldomain.com/SoapTest/webservicedemo.asmx"
actionThe action you want to call"HelloWorld"
paramsAn object of parameters to pass to the service{ name: "Andrew" }

Syntax:

$soap.get(url,action,params);

Similar to $http methods, $soap.get returns a promise that you can act upon.

$soap.get(url,action,params).then(function(response){//Do Stuff});

NOTE: Response will be a javascript object containing the response mapped to objects. Do a console.log of response so you can see what you are working with.

Example 1: Hello World

A basic "Hello World" with no parameters.

angular.module('myApp',['angularSoap']).factory("testService",['$soap',function($soap){varbase_url="http://www.cooldomain.com/SoapTest/webservicedemo.asmx";return{HelloWorld: function(){return$soap.get(base_url,"HelloWorld");}}}]).controller('MainCtrl',function($scope,testService){testService.HelloWorld().then(function(response){$scope.response=response;});})

Example 2: Invoke with Parameters

A basic method call with parameters.

angular.module('myApp',['angularSoap']).factory("testService",['$soap',function($soap){varbase_url="http://www.cooldomain.com/SoapTest/webservicedemo.asmx";return{CreateUser: function(firstName,lastName){return$soap.get(base_url,"CreateUser",{firstName: firstName,lastName: lastName});}}}]).controller('MainCtrl',function($scope,testService){testService.CreateUser($scope.firstName,$scope.lastName).then(function(response){$scope.response=response;});})

Example 3: Get Single Object

A basic method call to get a single object.

angular.module('myApp',['angularSoap']).factory("testService",['$soap',function($soap){varbase_url="http://www.cooldomain.com/SoapTest/webservicedemo.asmx";return{GetUser: function(id){return$soap.get(base_url,"GetUser",{id: id});}}}]).controller('MainCtrl',function($scope,testService){testService.GetUser($scope.id).then(function(user){console.log(user.firstName);console.log(user.lastName);});})

Example 4: Get Many Objects

A basic method call to get a collection of objects.

angular.module('myApp',['angularSoap']).factory("testService",['$soap',function($soap){varbase_url="http://www.cooldomain.com/SoapTest/webservicedemo.asmx";return{GetUsers: function(){return$soap.get(base_url,"GetUsers");}}}]).controller('MainCtrl',function($scope,testService){testService.GetUsers().then(function(users){for(i=0;i<users.length;i++){console.log(users[i].firstName);console.log(users[i].lastName);}});})

About

An angular port of a Javascript SOAP Client into a factory that has a similar syntax to $http.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages