具有wsdl自动发现功能的Zend Soap Server无法正常工作 [英] Zend Soap Server with wsdl autodiscovery doesn't work as expected

查看:108
本文介绍了具有wsdl自动发现功能的Zend Soap Server无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用wsdl自动发现模式下的Zend_Soap_Server创建一个Web服务,但是我得到了非常奇怪的效果……代码如下: 服务器:

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类:

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,此处为代码:

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;
    }

我无法理解,因为test2函数按预期工作,因此test1函数返回以下异常:

I cannot understand because the test2 function works as expected, the test1 function return the following exception:

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,数组) 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 {main}

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}

我试图将函数名称取反...结果令人难以置信,仅适用于test2!我疯了,似乎在服务器端的某个地方保存了函数名...

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...

有人可以帮助我吗?

推荐答案

已解决!问题是php.ini文件中的此设置:

SOLVED! The problem was this setting in the php.ini file:

soap.wsdl_cache_enabled=1

我将其设置为0,现在可以正常使用了!

I set this to 0 and now it works fine!

这篇关于具有wsdl自动发现功能的Zend Soap Server无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆