简体   繁体   中英

(Zend) Soap Server doesn't return results

I've been trying to setup a Soap Server using Zend_Soap_Server, but I can't seem to make it work.
I have tried several different environments: nginx and apache on a linux vm, apache on windows, php 5.3 and php 5.4, all yield the same results.

Using Zend_Soap_Autodiscover it correctly generates a wsdl. When I feed that wsdl to SoapClient and invoke a method on it, it doesn't return a response. It seems like php halts after SoapServer::handle() is called.

This is the server part:

ini_set('soap.enable_wsdl_cache', 0);

require_once 'Zend/Soap/AutoDiscover.php';
require_once 'Zend/Soap/Server.php';

if (isset($_GET['wsdl'])) {
    handleWsdl();
} else {
    handleSoap();
}

function handleWsdl() {
    $autodiscover = new Zend_Soap_AutoDiscover();
    $autodiscover->addFunction('pi');
    $autodiscover->handle();
}

function handleSoap() {
    $soap = new Zend_Soap_Server('http://localhost/experiments/soap/server.php?wsdl');
    $soap->setWsdlCache(false);
    $soap->addFunction('pi');
    $soap->handle();
}

And this is the client:

ini_set('soap.enable_wsdl_cache', 0);

$wsdl = 'http://localhost/experiments/soap/server.php?wsdl';
$client = new SoapClient($wsdl, array('trace' => 1));

$result = $client->pi();
var_dump($result);

The $result is NULL .

I'm running out of ideas and hope someone can help me solve this mystery.

BTW: I have also tried SoapUI to consume the webservice, but the results are the same.

maybe I have found the problem. Please check and report if it is correct with your vote. I have changed the way to call the Soap using the options and not the main uri parameter, in this way:

try{
        // initialize SOAP client
        $options = array(
                'location'  => 'http://localhost/experiments/soap/server.php',
                'uri'       => 'http://localhost/experiments/soap/server.php'
        );

        $client = new Zend_Soap_Client(null, $options);
        $result = $client->pi();
        Zend_Debug::dump($result);

    }catch(SoapFault $e){
        Zend_Debug::dump($e);
        echo $e->getMessage();
    }
}

If you call the WSDL the client cannot call the "pi()" method. Try it and let me know.

Regards

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM