简体   繁体   中英

Zend_Soap_Server/Client doesn't work. Returns “looks like we got no XML document”

I am working with Zend Framework, and I need to make a web service using Zend_Soap. After searching for 3 days, I've decided to ask myself. After creating Zend_Soap_Server i get message <SOAP-ENV ..> <SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode>sender</faultcode> <faultstring>Invalid XML</faultstring> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV> Then I tried this solution , and I got XML to work by using Zend_Soap_AutoDiscover, but when I try to connect 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());
}

the response I get is

looks like we got no XML document

The code on server ($soap is not used because I couldn't get it to work):

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

Try this approach in your controller:

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();

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