Php – Problems sending SOAP auth Headers in php


I am very new to SOAP (i.e. no clue!)

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 )

I have 3 methods at my disposal,


IsAlive simply returns true and I can call it no problem

IsAliveSecure returns true with proper authorisation and I cannot get it to return true.

basically I need to send the following request:

POST /ripplecomprovisioning.asmx HTTP/1.1
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: ""

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="" xmlns:xsd="" xmlns:soap="">
    <SoapAuthHeader xmlns="">
    <IsAliveSecure xmlns="" />

My question is how do I send a request formatted like the above in php?

this is what I tried but with no success:

$soapClient = new SoapClient("");

// Prepare SoapHeader parameters 
$sh_param = array( 
            'Username'    =>    'myusername', 
            'Password'    =>    'mypassword'); 
$headers = new SoapHeader('ripplecomprovisioning', 'SoapAuthHeaders', $sh_param); 

// Prepare Soap Client 
     $result = $soapClient->isAlive();

echo var_dump($result);

echo "<br /><br />";

   $result = $soapClient->IsAliveSecure();

echo var_dump($result);

the output from the above is as follows:

object(stdClass)#3 (1) {
<br /><br />
Fatal error: Uncaught SoapFault exception: [soap:Server] System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> 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->__call('IsAliveSecure', Array)
#1 /var/www/ripplecomweb/authentication/soap.php(20): SoapClient->IsAliveSecure()
#2 {main}
  thrown in /var/www/ripplecomweb/authentication/soap.php on line 20

Any help with this would be greatly appreciated. I cannot afford to fail!!



Best Solution

Well it would be a lot easier if we could see the WSDL of the service. But try these steps:

1.Check the WSDL for the isAliveSecure method to see if you have to pass something to it.

2.See what the request you're sending really looks like:


(make sure you're instantiating $soapClient with the option 'trace' => TRUE for these methods or they won't work -> see PHP manual).

3.Try sending the request in the form that you're sure should be correct manually via command line, something like:

curl -v -k -d @/path/to/the/file/with/the/request/xml http://service_url