简体   繁体   English

(Zend)Soap Server不返回结果

[英](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. 我一直在尝试使用Zend_Soap_Server设置Soap Server,但似乎无法使其正常工作。
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. 我尝试了几种不同的环境:Linux vm上的nginx和apache,Windows上的apache,php 5.3和php 5.4,它们都产生相同的结果。

Using Zend_Soap_Autodiscover it correctly generates a wsdl. 使用Zend_Soap_Autodiscover可以正确生成wsdl。 When I feed that wsdl to SoapClient and invoke a method on it, it doesn't return a response. 当我将wsdl喂给SoapClient并在其上调用方法时,它不会返回响应。 It seems like php halts after SoapServer::handle() is called. 在SoapServer :: handle()被调用之后,php似乎停止了。

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 . $resultNULL

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. 顺便说一句:我也尝试了SoapUI来使用Web服务,但是结果是相同的。

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: 我已经更改了使用选项而不是主要uri参数调用Soap的方式,方法是:

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. 如果您调用WSDL,客户端将无法调用“ pi()”方法。 Try it and let me know. 试试看,让我知道。

Regards 问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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