Zend_Soap_Server / Client不起作用。返回“看起来我们没有XML文档”

时间:2016-08-29 14:00:59

标签: php soap zend-framework

我正在使用Zend Framework,我需要使用Zend_Soap创建一个Web服务。搜索了3天后,我决定问自己。创建Zend_Soap_Server后,我收到消息 <SOAP-ENV ..> <SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode>sender</faultcode> <faultstring>Invalid XML</faultstring> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV> 然后我尝试了this solution,使用Zend_Soap_AutoDiscover让XML工作,但是当我尝试连接Zend_Soap_Client时...

<?php

require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Soap_Client');

$options  = array(
    'location' => 'http://zend/service/soap',
    'uri' => 'http://zend/service/soap'
);
try {
    $client = new Zend_Soap_Client(null, $options);
    $foo = $client->foo();
    var_dump($foo);
} catch (Exception $e) {
    die($e->getMessage());
}

我得到的回应是

  

看起来我们没有XML文档

服务器上的代码($ soap未使用,因为我无法使其工作):

public function soapAction() {
    $this->_helper->layout()->disableLayout();
    $this->getHelper('viewRenderer')->setNoRender(true);
    $soap   =   new Zend_Soap_Server(null,array(
        'uri' => 'http://zend/service/soap'
    ));
    $soap->setClass('API_SoapFunctions');
    $soap->setUri('http://zend/service/soap');
    $autodiscover = new Zend_Soap_AutoDiscover();
    $autodiscover->setClass('API_SoapFunctions')->setBindingStyle(array('style' => 'document'))->setUri('http://zend/service/soap');
    header('Content-type: application/xml');
    echo $autodiscover->toXml();
    //$soap->handle();
}

1 个答案:

答案 0 :(得分:0)

在您的控制器中尝试此方法:

if(check if you have a request for WSDL){
    $server = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex');
}else{
    $server = new Zend_Soap_Server('URI_HERE'); 
}
$server->setClass('WS_CLASS_HERE');
$server->handle();