PHP 致命错误:“消息中指定的 SOAP 操作''与 HTTP SOAP 操作不匹配" [英] PHP Fatal error: "The SOAP action specified on the message, '', does not match the HTTP SOAP Action"

查看:39
本文介绍了PHP 致命错误:“消息中指定的 SOAP 操作''与 HTTP SOAP 操作不匹配"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个 PHP 脚本,该脚本将连接到我们 SightMax 界面的 SOAP 客户端.使用下面的代码,我可以打印出可用函数列表,但是当我尝试调用任何函数时,我收到以下错误.

 SOAP_1_2));var_dump($client->__getFunctions());$result = $client->__call("GetSiteSummary", array());echo "

";打印_r($result);echo "</pre>";?>

<小时>

致命错误:未捕获的 SoapFault 异常:[s:Sender] 消息中指定的 SOAP 操作'"与 HTTP SOAP 操作SmartMax.SightMax.Agent.Operator/IRemotedWebsiteAdministrator/GetSiteSummary"不匹配.在 test2.php:7 堆栈跟踪中:#0 test2.php(7): SoapClient->__call('GetSiteSummary', Array) #1 {main} 在第 7 行的 test2.php 中抛出

过去几天我一直在研究这个错误,我阅读了不同的文章,说明了可能存在的问题.据我了解,发生此错误是因为 SOAP 客户端是为 wsHttpBinding 配置的,而 PHP 的 SOAP 客户端中的构建不支持 wsHttpBinding,或者我需要专门指定 SOAP 操作.

谁能帮我解释一下?请记住,虽然我精通 PHP,但使用 SOAP 对我来说是新手,所以按步骤操作非常有帮助.

提前致谢.

解决方案

WCF 似乎在 SOAP 信封中寻找操作.您可以通过这种方式使用 PHP 的 SoapClient 将其添加到您的调用中:

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

如果您更改第三个参数并在 $client 的实例化和 __call() 之间添加该参数,它应该会清除错误(并且可能带来新的错误,SOAP 不是很有趣吗?)

另外仅供参考,刚刚经历了同样的问题,我发现 __getLastRequestHeaders()、__getLastRequest()、__getLastResponseHeaders() 和 __getLastResponse() 函数非常方便,可以查看我尝试的方法是否有任何效果(请注意,您需要将trace"=>1"添加到您的 SoapClient 选项中,以便它们工作.)

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.

解决方案

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

这篇关于PHP 致命错误:“消息中指定的 SOAP 操作''与 HTTP SOAP 操作不匹配"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆