副本这个问题

我正在尝试使用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();
    }
.

SOAPACTIONT等级:

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异常:[发件人]函数 (“test1”)不是一个有效的方法 这项服务in. /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 - > __呼叫('test1', 大批) 2 /usr/local/zend/apache2/htdocs/webservice/client.php(6): zend_soap_client-> test1('foo','bar') 3 {main}

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

有人可以帮助我吗?

有帮助吗?

解决方案

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

soap.wsdl_cache_enabled=1

I set this to 0 and now it works fine!

其他提示

If you don't want change your php.ini:

// WSDL_CACHE_NONE;     /* 0 Pas de cache */
// WSDL_CACHE_DISK;     /* 1 Sur le disque supprimer le fichier pour le réinitialiser */
// WSDL_CACHE_MEMORY;   /* 2 En mémoire => redémarrer Apache pour le réinitialiser */
// WSDL_CACHE_BOTH;     /* 3 En mémoire et sur le disque */

$options = array();
$options['cache_wsdl'] = WSDL_CACHE_NONE;
$client = new Zend_Soap_Client("http://localhost:8083/server.php?wsdl", $options);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top