PHP 致命错误:“消息上指定的 SOAP 操作,与 HTTP SOAP 操作不匹配”

发布于 2024-12-28 02:42:53 字数 1030 浏览 0 评论 0原文

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

<?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 

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

谁能帮我解释一下吗?请记住,虽然我熟悉 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光磨忆 2025-01-04 02:42:53

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

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

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

另外仅供参考,刚刚经历了同样的问题,我发现了 __getLastRequestHeaders()、__getLastRequest()、__getLastResponseHeaders() 和__getLastResponse() 函数非常方便地查看我正在尝试的内容是否有任何效果(请注意,您需要将“trace”=>“1”添加到 SoapClient 选项中才能使这些选项起作用。)

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

沉鱼一梦 2025-01-04 02:42:53

您应该给出 SOAP 操作。由于您没有将其包含在 SoapClient 的初始化中,因此它与 Web 服务的 SOAP 操作不匹配。连接之前请确保您知道 SOAP 操作是什么。

阅读 http://www.oreillynet.com/xml/blog/2002/11/unraveling_the_mystery_of_soap.html" oreillynet.com/xml/blog/2002/11/unraveling_the_mystery_of_soap.html 了解更多信息 主题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文