Web services 在PHP中使用Zend框架设置SOAP Web服务

Web services 在PHP中使用Zend框架设置SOAP Web服务,web-services,zend-framework,soap,routing,client,Web Services,Zend Framework,Soap,Routing,Client,我正在尝试使用标准Zend Framework项目设置Web服务 错误 Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://localhost/webservice/index' : Extra content at the end of the document in C:\wamp\www\delegate-events-portal

我正在尝试使用标准Zend Framework项目设置Web服务

错误

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: 
Couldn't load from 'http://localhost/webservice/index' : Extra content at the end 
of the document in 
C:\wamp\www\delegate-events-portal\library\Zend\Soap\Client\Common.php:51 
Stack trace: #0 
C:\wamp\www\delegate-events-portal\library\Zend\Soap\Client\Common.php(51): 
SoapClient->SoapClient('http://localhos...', Array) #1 
C:\wamp\www\delegate-events-portal\library\Zend\Soap\Client.php(1026): 
Zend_Soap_Client_Common->__construct(Array, 'http://localhos...', Array) #2 
C:\wamp\www\delegate-events-portal\library\Zend\Soap\Client.php(1182): 
Zend_Soap_Client->_initSoapClientObject() #3 
C:\wamp\www\delegate-events-portal\library\Zend\Soap\Client.php(1106): 
Zend_Soap_Client->getSoapClient() #4 [internal function]: 
Zend_Soap_Client->__call('getCompanies', Array) #5 
C:\wamp\www\delegate-events-portal\application\controllers
\WebserviceController.php(98): 
Zend_Soap_Client->getCompanies() #6 
C:\wamp\www\delegate-events-portal\application\controllers\WebserviceC in 
C:\wamp\www\delegate-events-portal\library\Zend\Soap\Client\Common.php on line 51
代码

应用程序/controllers/WebserviceController.php

class WebserviceController extends Portal_BaseController
{
    public $resourceId = 'Webservice';
    private $client;

    public function init(){}

    public function indexAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        //Set up the Web Service Manager
        $auto = new Zend_Soap_AutoDiscover();
        $auto->setClass('Webservice_Manager');
        $auto->handle();
    }

    public function clientAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        try
        {
            $this->client = new Zend_Soap_Client('http://localhost/webservice/index');
        }
        catch(SoapFault $s)
        {
            echo '<pre>';
            print_r($s);
            echo '<pre>';
            die('ERROR: [' . $s->faultcode . '] ' . $s->faultstring);
        }
        catch (Exception $e)
        {
            die('ERROR: ' . $e->getMessage());
        }

        print_r($this->client->getCompanies());
    }
}
潜在解决方案

我很确定这个问题是由Zend中的路由系统引起的。当我获取服务器代码并将其放在框架之外(根文件夹中)时,代码工作正常。在这个场景中,我对代码所做的唯一更改是wsdl的位置。我使用了一个绝对路径,需要任何我需要的文件

考虑到这一点,我如何让web服务在Zend项目内部工作,而不是在外部工作


任何帮助都将不胜感激。我要把头发扯下来了

尝试更改
索引操作
以使用
Zend\u Soap\u服务器
。它不是自动发现,而是完成任务


您为什么要扩展
Portal\u BaseController
?它是否扩展了Zend_控制器动作?此外,此应用程序是作为服务器还是客户端?我问这个问题的原因是因为我假设您正在编写一个服务器应用程序,但是我没有看到任何代码来实例化
Zend_Soap_服务器
对象。欢迎使用堆栈溢出!你会考虑添加一些叙述来解释这个代码为什么工作,什么使它成为问题的答案?这对提出问题的人和其他任何人都非常有帮助。
class Webservice_Manager
{

    /**
     * Returns all the companies for a particular summit
     * @param int $summitID
     * @return array
     */
    public function getCompanies($summitID = 118)
    {
        $companiesModel = new Application_Model_DbTable_Company();
        return $companiesModel->getCompaniesAndAttendees($summitID, NULL, NULL, true, NULL)->toArray();
    }

    /**
     * Returns all the attendees for a particular summit
     * @param int $summitID
     * @param int $companyID
     * @return array
     */
    public function getAttendees($summitID = 118, $companyID = 3767) 
    {
        $attendeesModel = new Application_Model_DbTable_Attendee();
        return $attendeesModel->getAttendees($summitID, $companyID, false)->toArray();
    }
}
public function indexAction()
{
    $this->_helper->layout->disableLayout();
    $this->_helper->viewRenderer->setNoRender(true);

    //Set up the Web Service Manager
    $auto = new Zend_Soap_Server(null, array(
        'uri' => 'http://localhost/webservice/index'
    ));
    $auto->setClass('Webservice_Manager');
    $auto->handle();
}
public function webserviceAction(){
     $this->_helper->layout->disableLayout();`enter code here`       
    $this->_helper->viewRenderer->setNoRender(true);
    //Set up the Web Service
        $auto = new Zend_Soap_Server(null, array(
        'uri' => 'http://localhost/webservice/webservice'
    ));
        $auto->setClass('Webservice_Manager');
        $auto->handle();
}