Zend Soap Server con WSDL AutoDiscovery no funciona como se esperaba
-
15-11-2019 - |
Pregunta
duplicado de esta pregunta
Estoy tratando de crear un servicio web con Zend_SoAP_SERVER en modo AutoDiscovery WSDL, pero obtengo efectos muy extraños ... aquí el 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();
}
Clase de SOAPACTS:
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;
}
}
Intenté usar la función Test1 y Test2 usando la clase Zend_SoAP_CLIENT, aquí el 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;
}
No puedo entender porque la función TEST2 funciona como se espera, la función Test1 devuelve la siguiente excepción:
EXCEPCIÓN DEFAULTE: FUNCIÓN [SENDER] ("Test1") no es un método válido para Este servicio en /usr/local/zend/share/zendframework/library/zend/soap/client.php:1121 Rastreo de la pila: 0 /usr/local/zend/share/zendframework/library/zend/soap/client.php(1121): Soapclient -> __ Soapcall ('test1', matriz, Nulo, nulo, matriz) 1 /usr/local/zend/apache2/htdocs/webservice/client.php(6): Zend_soap_client -> __ llamada ('test1', Formación) 2 /usr/local/zend/apache2/htdocs/webservice/client.php(6): Zend_soap_client-> test1 ('foo', 'bar') 3 {main}
Intenté invertir el nombre de las funciones ... ¡El resultado es increíble, solo funciona Test2! Me estoy volviendo loco, parece que en algún lugar del lado del servidor, guarda el nombre de la función ...
¿Puede alguien ayudarme?
Solución
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!
Otros consejos
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);