問題描述
我正在嘗試編寫一個 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 操作不匹配"的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!