title: Problems sending SOAP auth Headers in php
body: <p>I am very new to SOAP (i.e. no clue!)</p>
  
  <p>I have been asked by a client to interact with an existing SOAP service that requires authentication done through my SOAP headers ( a simple username and password ) </p>
  
  <p>I have 3 methods at my disposal,</p>
  
  <p>IsAlive
  IsAliveSecure
  ChangeUserDetails</p>
  
  <p>IsAlive simply returns true and I can call it no problem</p>
  
  <p>IsAliveSecure returns true with proper authorisation and I cannot get it to return true.</p>
  
  <p>basically I need to send the following request:</p>
  
  <pre><code>POST /ripplecomprovisioning.asmx HTTP/1.1
  Host: provisioning.example.ie
  Content-Type: text/xml; charset=utf-8
  Content-Length: length
  SOAPAction: "http://www.blueface.ie/provisioning/IsAliveSecure"
  
  &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:Header&gt;
      &lt;SoapAuthHeader xmlns="http://www.example.ie/provisioning/"&gt;
        &lt;Username&gt;myusername&lt;/Username&gt;
        &lt;Password&gt;mypassword&lt;/Password&gt;
      &lt;/SoapAuthHeader&gt;
    &lt;/soap:Header&gt;
    &lt;soap:Body&gt;
      &lt;IsAliveSecure xmlns="http://www.example.ie/provisioning/" /&gt;
    &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>My question is how do I send a request formatted like the above in php?</p>
  
  <p>this is what I tried but with no success:</p>
  
  <p>$soapClient = new SoapClient("https://provisioning.example.ie/ripplecomprovisioning.asmx?WSDL"); </p>
  
  <pre><code>// Prepare SoapHeader parameters 
  $sh_param = array( 
              'Username'    =&gt;    'myusername', 
              'Password'    =&gt;    'mypassword'); 
  $headers = new SoapHeader('ripplecomprovisioning', 'SoapAuthHeaders', $sh_param); 
  
  // Prepare Soap Client 
  $soapClient-&gt;__setSoapHeaders(array($headers)); 
       $result = $soapClient-&gt;isAlive();
  
  echo var_dump($result);
  
  echo "&lt;br /&gt;&lt;br /&gt;";
  
     $result = $soapClient-&gt;IsAliveSecure();
  
  echo var_dump($result);
  </code></pre>
  
  <p>the output from the above is as follows:</p>
  
  <pre><code>object(stdClass)#3 (1) {
    ["IsAliveResult"]=&gt;
    bool(true)
  }
  &lt;br /&gt;&lt;br /&gt;
  Fatal error: Uncaught SoapFault exception: [soap:Server] System.Web.Services.Protocols.SoapException: Server was unable to process request. ---&gt; System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.
     at example.VoIP.Provisioning.RipplecomProvisioningServices.IsAliveSecure()
     --- End of inner exception stack trace --- in /var/www/ripplecomweb/authentication/soap.php:20
  Stack trace:
  #0 [internal function]: SoapClient-&gt;__call('IsAliveSecure', Array)
  #1 /var/www/ripplecomweb/authentication/soap.php(20): SoapClient-&gt;IsAliveSecure()
  #2 {main}
    thrown in /var/www/ripplecomweb/authentication/soap.php on line 20
  </code></pre>
  
  <p>Any help with this would be greatly appreciated. I cannot afford to fail!! </p>
  
  <p>Thanks</p>
  
  <p>Kev</p>