1

我有下面的代码

class ReservationController extends Zend_Controller_Action
{
    public function init()
    {
    }

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

        $soap = new Zend_Rest_Server();
        $soap->setClass('Someclass');

        $soap->handle();
    }
}

<?php

class IndexController extends Zend_Controller_Action
{
private $_URI = "http://www.mysite.local/crm/reservation";
    public function clientAction() {
        $this->_helper->viewRenderer->setNoRender();
        $this->_helper->layout->disableLayout();
        $client = new Zend_Rest_Client($this->_URI);
       echo $client->sayHello('nisanth')->get();

    }

}

类和方法为

<?php
class Someclass
{
/**
* Say Hello
*
* @param string $who
* @return string
*/
function sayHello($who)
{
    return "Hello $who";

}
} 

但是在调用这个时我得到了一个错误

消息:REST 响应错误:simplexml_load_string() [function.simplexml-load-string]:^

请帮我解决这个问题

4

1 回答 1

0

听起来您没有从 REST 请求中返回 XML 响应。SimpleXML 仅在没有获得有效的 XML 作为参数时才会失败。

确保您的 REST 服务器实际使用 Zend_REST_Server,它将函数的返回值输出到 XML 响应中。

有关 Zend_Rest_Client 如何工作的更多信息:http: //framework.zend.com/manual/en/zend.rest.client.html

有关 Zend_Rest_Server 的更多信息:http: //framework.zend.com/manual/en/zend.rest.server.html

于 2010-06-23T21:46:51.797 回答