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

查看:26
本文介绍了具有 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 异常:[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、数组)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 {主要}

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

有人可以帮我吗?

推荐答案

SOLVED!问题出在 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天全站免登陆