Pergunta

Duplicado de essa questão

Estou tentando criar um serviço web com Zend_Soap_Server em modo de autodescoberta wsdl, mas obtenho efeitos muito estranhos...aqui o código:servidor:

<?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();
    }

Classe SoapActions:

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

}

Tentei utilizar a função test1 e test2 utilizando a classe Zend_Soap_Client, aqui o código:

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

Não consigo entender porque a função test2 funciona conforme o esperado, a função test1 retorna a seguinte exceção:

Exceção SoapFault:Remetente] função ("test1") não é um método válido para este serviço em /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}

Tentei inverter o nome das funções...o resultado é incrível, funciona apenas test2!Estou ficando louco, parece que em algum lugar do lado do servidor ele salva o nome da função...

Alguém pode me ajudar?

Foi útil?

Solução

RESOLVIDO!O problema foi esta configuração no arquivo php.ini:

soap.wsdl_cache_enabled=1

Eu configurei isso para 0 e agora funciona bem!

Outras dicas

Se você não quiser alterar seu 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);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top