how to consume asmx web service using AngularJS

1.2k views Asked by At

OK. I am a PHP developer and I am a newbie to AngularJS. I have been searching for days trying to find the correct way to connect with an ASMX web service including parameters which returns XML. Right now, it is working in PHP but I want to convert over to AngularJS. So here are the parameters I need to send over on the call:

uuid: 'my access token', options: 'attributes=1', querystring: 'condition=2'

and

form: 'POST'

And YES, I have to use POST and not GET on this call even though all I am doing is receiving a large deep multidimensional xml array. So here is what I have right now:

<!doctype>
<html ng-app="myApp">
<head>

 <body ng-controller="MyController">  

  {{ response }}

  </body>

<script>
angular.module("myApp", []).controller("MyController",   function($scope, $http){

$http({
url:"http://www.dlrwebservice.com/InventoryServiceRV.asmx/GetInventoryDataXML",
method:"POST", 
headers:{'Content-Type': 'application/xml'},
config: { uuid: 'my actual uuid', options: 'attributeNo=1', querystring: 'condition=2'}

  }).success(function(data, status, headers, config) {

  $scope.response = data;

   //here data is response from server. You can check status, headers, configuration settings too. 

  }).error(function(data, status, headers, config) {

  //do something here. Error occurd while fetching data from server

  });
  });



  </script>
  </html>

I keep getting this error: XMLHttpRequest cannot load http://www.dlrwebservice.com/InventoryServiceRV.asmx/GetInventoryDataXML. No 'Access-Control-Allow-Origin' header is present on the requested resource.

Thanks in advance for any help!!!

0

There are 0 answers