Question

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?

Was it helpful?

Solution

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!

OTHER TIPS

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top