2016-08-29 37 views
0

我正在使用Zend框架,并且我需要使用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,我得到XML使用Zend_Soap_AutoDiscover工作,但是当我尝试连接Zend_Soap_Client ...Zend_Soap_Server/Client不起作用。返回“看起来像我们没有XML文档”

<?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文档

在服务器上的代码($肥皂不使用,因为我无法得到它的工作):

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(); 
} 
+0

我刚刚问...你不使用URI'HTTP://的Zend /服务/ soap'当你运行你的代码,对吧? –

+0

我在公用文件夹index.php旁边有一个文件service.php –

+0

当然,在上面的代码中,你有'http:// zend/service/soap'作为URL,而不是'service.php'文件。上面的代码是你的实际代码吗? –

回答

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(); 
相关问题