title: How to consume a SOAP WebService with AngularJS?
body: <p>Well, I have a SOAP WebService that is consumed usually for a PHP client, working perfectly ... by ajax consumption this php and populate my template ..</p>
  
  <p>My current application does the following process <code>Angular &lt;-&gt; PHP &lt;-&gt; service.wsdl</code></p>
  
  <p>I discovered the possibility of excluding this PHP bridge, directly consuming SOAP WebService, using <a href="https://github.com/andrewmcgivery/angular-soap" rel="nofollow">angular-soap</a> .</p>
  
  <p>But when playing the example, I can not return any information .. or error.</p>
  
  <p>index.html</p>
  
  <pre><code>&lt;html ng-app="myApp"&gt;
      &lt;head&gt;
          &lt;script src="public/js/angular.js"&gt;&lt;/script&gt;
          &lt;script src="public/js/soapclient.js"&gt;&lt;/script&gt;
          &lt;script src="public/js/angular.soap.js"&gt;&lt;/script&gt;
  
          &lt;script&gt;
              angular.module('myApp', ['angularSoap'])
  
              .factory("testService", ['$soap',function($soap){
                  var base_url = "http://localhost/api/1/service.wsdl";
  
                  return {
                      getEmpresa: function(){
                          var x =  $soap.post(base_url,"getEmpresas");
                          return x;
                      }
                  }
              }])
  
              .controller('MainCtrl', function($scope, testService) {
  
                testService.getEmpresa().then(function(response){
                  $scope.response = response;
                });
  
              })
          &lt;/script&gt;
  
      &lt;/head&gt;
      &lt;body ng-controller="MainCtrl"&gt;
          {{response}}
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>service wsdl</p>
  
  <pre><code>&lt;!--  WSDL file generated by Zend Studio.  --&gt;
  &lt;definitions xmlns:typens="urn:Service" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" name="Service" targetNamespace="urn:Service"&gt;
      &lt;message name="getEmpresas"&gt;
          &lt;part name="getEmpresas" type="xsd:string"/&gt;
      &lt;/message&gt;
      &lt;message name="getEmpresasResponse"&gt;
          &lt;part name="getEmpresasReturn" type="xsd:string"/&gt;
      &lt;/message&gt;
      &lt;portType name="HomePortType"&gt;
          &lt;operation name="getEmpresas"&gt;
              &lt;input message="typens:getEmpresas"/&gt;
              &lt;output message="typens:getEmpresasResponse"/&gt;
          &lt;/operation&gt;
      &lt;/portType&gt;
      &lt;binding name="HomeBinding" type="typens:HomePortType"&gt;
          &lt;soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/&gt;
          &lt;operation name="getEmpresas"&gt;
              &lt;soap:operation soapAction="urn:HomeAction"/&gt;
              &lt;input&gt;
                  &lt;soap:body namespace="urn:Service" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/&gt;
              &lt;/input&gt;
              &lt;output&gt;
                  &lt;soap:body namespace="urn:Service" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/&gt;
              &lt;/output&gt;
          &lt;/operation&gt;
      &lt;/binding&gt;
      &lt;service name="ServiceService"&gt;
          &lt;port name="HomePort" binding="typens:HomeBinding"&gt;
              &lt;soap:address location="http://localhost/app/homeCrtl.php"/&gt;
          &lt;/port&gt;
      &lt;/service&gt;
  &lt;/definitions&gt;
  </code></pre>
  
  <p>When you make the request it sends an envelope via Request Payload.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
         &lt;soap:Body&gt;
            &lt;getEmpresas xmlns="urn:Service"&gt;&lt;/getEmpresas&gt;
         &lt;/soap:Body&gt;
      &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>the browser tool for <code>network &gt; Response</code> he returns my own wsdl described above ..</p>
  
  <p>you need / have to change something on the server?</p>
  
  <p>thank you</p>