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

给你一囗甜甜゛ 提交于 2019-12-17 16:59:14

问题


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.


回答1:


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.)




回答2:


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.



来源:https://stackoverflow.com/questions/8934365/php-fatal-error-the-soap-action-specified-on-the-message-does-not-match-t

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!