具有 wsdl 自动发现功能的 Zend Soap Server 无法按预期工作
我试图在 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();
}
SoapActions class:
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, 空、空、数组) 1 /usr/local/zend/apache2/htdocs/webservice/client.php(6): Zend_Soap_Client->__call('test1', 大批) 2 /usr/local/zend/apache2/htdocs/webservice/client.php(6): Zend_Soap_Client->test1('foo', 'bar') 3 {主要}
我尝试反转函数名称...结果令人难以置信,仅适用于 test2!我快疯了,似乎在服务器端的某个地方保存了函数名称......
有人可以帮助我吗?
Duplicate of this question
I'm trying to create a web service with Zend_Soap_Server in wsdl autodiscovery mode, but I obtain very strange effects... here the code:
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();
}
SoapActions class:
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;
}
}
I tried to use the function test1 and test2 using the Zend_Soap_Client class, here the code:
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;
}
I cannot understand because the test2 function works as expected, the test1 function return the following exception:
SoapFault exception: [Sender] Function
("test1") is not a valid method for
this service in
/usr/local/zend/share/ZendFramework/library/Zend/Soap/Client.php:1121
Stack trace:
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}
I tried to invert the functions name... the result is incredible, works only test2! I'm getting crazy, it seems that somewhere on server side it save the function name...
Can someone help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决了!问题出在 php.ini 文件中的这个设置:
我将其设置为
0
,现在它工作正常!SOLVED! The problem was this setting in the php.ini file:
I set this to
0
and now it works fine!如果您不想更改 php.ini:
If you don't want change your php.ini: