Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Fatal error: "The SOAP action specified on the message, '', does not match the HTTP SOAP Action"

Tags:

php

soap

I'm attempting to write a PHP script that will connect to the SOAP client for our SightMax interface. With the code below I am able to print out a list of functions available however when I try and call any function I am getting the the following error.

<?php

$client = new SoapClient('http://domain.com/SightMaxWebServices/SightMaxWebService.svc?wsdl', array('soap_version' => SOAP_1_2));

var_dump($client->__getFunctions());

$result = $client->__call("GetSiteSummary", array());

echo "<pre>";
print_r($result);
echo "</pre>";

?>

Fatal error: Uncaught SoapFault exception: [s:Sender] The SOAP action specified on the message, '', does not match the HTTP SOAP Action, 'SmartMax.SightMax.Agent.Operator/IRemotedWebsiteAdministrator/GetSiteSummary'. in test2.php:7 Stack trace: #0 test2.php(7): SoapClient->__call('GetSiteSummary', Array) #1 {main} thrown in test2.php on line 7 

I've been researching this error for the last couple days and I've read different articles stating possible issues. From what I understand this error occurs because the SOAP client is configured for wsHttpBinding and either the build in SOAP client for PHP does not support the wsHttpBinding or I need to specifically specify the SOAP action.

Can anyone shed any light on this for me? Please keep in mind while I'm versed with PHP working with SOAP is new to me so step by steps are very helpful.

Thanks in Advance.

like image 977
Larry Dougherty Avatar asked Jan 19 '12 22:01

Larry Dougherty


2 Answers

WCF seems to be looking for the action in the SOAP envelope. You can add it to your call with PHP's SoapClient this way:

$actionHeader = new SoapHeader('http://www.w3.org/2005/08/addressing',
                               'Action',
                               'http://soapaction.that.was.in.the.wsdl');
$client->__setSoapHeaders($actionHeader);

If you change the third parameter and add that between your instantiation of $client and the __call() it should clear the error (and possibly bring on new ones, isn't SOAP fun?)

Also FYI, having just gone through this same problem, I found the __getLastRequestHeaders(), __getLastRequest(), __getLastResponseHeaders(), and __getLastResponse() functions very handy to see if what I was trying had any effect (note that you need to add "trace" => "1" to your SoapClient options for those to work.)

like image 86
jasondoucette Avatar answered Nov 17 '22 10:11

jasondoucette


You should give the SOAP Action. Since you do not include it in the initialization of SoapClient, it doesn't match the SOAP Action of the web service. Make sure you know what the SOAP Action is before connecting.

Read http://www.oreillynet.com/xml/blog/2002/11/unraveling_the_mystery_of_soap.html for more on the subject.

like image 31
Leonard Avatar answered Nov 17 '22 09:11

Leonard