Domanda

Duplicato di Questa domanda

Sto cercando di creare un servizio Web con Zend_SoAP_Server in modalità AutoDiscovery WSDL, ma ottengo effetti molto strani ... Ecco il codice: 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();
    }
.

Classe Pearactions:

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

}

Ho provato a utilizzare la funzione Test1 e Test2 utilizzando la classe Zend_SoAP_Client, qui il codice:

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

Non riesco a capire perché la funzione Test2 funziona come previsto, la funzione Test1 restituisce la seguente eccezione:

.

Eccezione Sovpfault: funzione [mittente] ("Test1") non è un metodo valido per questo servizio 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 -> __ Chiamata ('Test1', Vettore) 2 /usr/local/zend/apache2/htdocs/webservice/client.php(6): Zend_soap_client-> test1 ('foo', 'bar') 3 {Main}

Ho provato a invertire il nome delle funzioni ... Il risultato è incredibile, funziona solo Test2! Mi sto impazzendo, sembra che da qualche parte sul lato server Salva il nome della funzione ...

Qualcuno può aiutarmi?

È stato utile?

Soluzione

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!

Altri suggerimenti

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);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top