这个问题的重复
我正在尝试在 wsdl 自动发现模式下使用 Zend_Soap_Server 创建一个 Web 服务,但我得到了非常奇怪的效果......这里的代码:服务器:
<?php
require_once('Zend/Soap/AutoDiscover.php');
require_once('Zend/Soap/Server.php');
require_once('Zend/Soap/Wsdl.php');
require_once('library/SoapActions.php');
$wsdl = new Zend_Soap_Autodiscover();
$wsdl->setClass('SoapActions');
if (isset($_GET['wsdl'])) {
$wsdl->handle();
} else {
$server = new Zend_Soap_Server('http://localhost:8083/server.php?wsdl');
$server->setClass('SoapActions');
$server->setEncoding('ISO-8859-1');
$server->handle();
}
肥皂动作类:
class SoapActions {
/**
* Test function
*
* @param String $a
* @param String $b
* @return String
*/
public function test1($a, $b) {
return "you passed me ".$a." ".$b;
}
/**
* Test function 2
*
* @param String $a
* @param String $b
* @return String
*/
public function test2($a, $b) {
return "you passed me ".$a." ".$b;
}
}
我尝试使用 Zend_Soap_Client 类来使用函数 test1 和 test2,这里是代码:
require_once('Zend/Soap/Client.php');
$client = new Zend_Soap_Client("http://localhost:8083/server.php?wsdl");
try {
echo $client->test2("foo","bar"); //this works!
} catch (Exception $e) {
echo $e;
}
try {
echo $client->test1("foo","bar"); //this doesn't work!
} catch (Exception $e) {
echo $e;
}
我无法理解,因为 test2 函数按预期工作, test1 函数返回以下异常:
SoapFault 异常:[Sender] 函数(“test1”)不是 /usr/local/zend/share/ZendFramework/library/Zend/Soap/Client.php:1121 中此服务的有效方法堆栈跟踪:0 /usr/ local/zend/share/ZendFramework/library/Zend/Soap/Client.php(1121): SoapClient->__soapCall('test1', Array, NULL, NULL, Array) 1 /usr/local/zend/apache2/htdocs/ webservice/client.php(6): Zend_Soap_Client->__call('test1', Array) 2 /usr/local/zend/apache2/htdocs/webservice/client.php(6): Zend_Soap_Client->test1('foo', '酒吧') 3 {主要}
我试图反转函数名称......结果令人难以置信,仅适用于 test2!我快疯了,似乎在服务器端的某个地方保存了函数名......
有人能帮我吗?