【发布时间】:2012-01-19 22:32:15
【问题描述】:
我正在尝试为我们的 SightMax 接口编写一个连接到 SOAP 客户端的 PHP 脚本。使用下面的代码,我可以打印出可用函数列表,但是当我尝试调用任何函数时,我会收到以下错误。
<?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 对我来说是新的,所以一步一步非常有帮助。
提前致谢。
【问题讨论】:
-
你试过省略
new SoapClient中的版本参数吗? Soap 1.2 不使用 SOAP 操作标头,而 1.1 使用。可能是,服务器只理解 1.1? -
当我删除 SOAP_1_2 版本参数时,我得到一个不同的错误致命错误:未捕获的 SoapFault 异常:[HTTP] 无法处理消息,因为内容类型为 'text/xml; charset=utf-8' 不是预期的类型 'application/soap+xml;字符集=utf-8'。在 test2.php:5 堆栈跟踪:#0 [内部函数]:SoapClient->__doRequest('__call('GetSiteSummary', Array) #2 {main} 在 /var/www/tools/html/whoseonchat/test2 中抛出。第5行的php