I am trying to make a simple service call using SOAP services in AngularJS based on this page http://mcgivery.com/soap-web-services-angular-ionic/
But I am getting this error: Error: [$injector:unpr] http://errors.angularjs.org/1.4.3/$injector/unpr?p0=%24soapProvider%20%3C-%20%24soap%20%3C-%20CallService
this is my code:
index.html
<!doctype html>
<html>
<head lang="en">
<meta charset="UTF-8">
<script src="angular.min.js"></script>
<script src="soapclient.js"></script>
<script src="angular.soap.js"></script>
</head>
<body>
<form method="post" action="">
<div ng-app="myApp" ng-controller="MainCtrl">
<div>
<input type="button" value="Call Web Service - Test" ng-click="CallService();" />
</div>
</div>
</form>
<script src="app.js"></script>
</body>
</html>
app.js
var app = angular.module('myApp', [])
app.factory("CallService", ['$soap',function($soap){
var base_url = "http://10.0.0.70:8080/WS_usrService/WS_usr?wsdl";
return {
getAll: function(){
return $soap.post(base_url, "getAll");
}
}
}])
app.controller('MainCtrl', function($scope, CallService) {
CallService.getAll().then(function(response){
$scope.response = response;
}, function(){
console.log("Something went wrong!");
});
})
Thank you
The error message indicates that Angular cannot find the service $soap
, which is defined on the module angularSoap
.
According to the official guide, add the module dependency as:
var app = angular.module('myApp', ['angularSoap'])