sal*_*gua 1 soap wsdl zend-framework zend-soap
这个问题重复一遍
我正在尝试使用wsdl自动发现模式中的Zend_Soap_Server创建一个Web服务,但我获得了非常奇怪的效果......这里代码:server:
<?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();
}
Run Code Online (Sandbox Code Playgroud)
SoapActions类:
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;
}
Run Code Online (Sandbox Code Playgroud)
}
我尝试使用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;
}
Run Code Online (Sandbox Code Playgroud)
我无法理解因为test2函数按预期工作,test1函数返回以下异常:
SoapFault异常:[发件人]函数("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', 'bar')3 {main}
我试图反转函数名称...结果令人难以置信,仅适用于test2!我疯了,似乎在服务器端的某个地方保存了功能名称......
有人能帮我吗?
解决了!问题是php.ini文件中的这个设置:
soap.wsdl_cache_enabled=1
Run Code Online (Sandbox Code Playgroud)
我把0它设置为现在它工作正常!