【问题标题】:Zend Rest Client issueZend Rest 客户端问题
【发布时间】:2010-06-03 12:25:12
【问题描述】:

我有下面的代码

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]: ^

请帮我解决这个问题

【问题讨论】:

  • 刚刚遇到同样的错误信息。

标签: web-services rest zend-framework php zend-rest


【解决方案1】:

听起来您没有从 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

【讨论】:

    猜你喜欢
    • 2018-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-20
    • 1970-01-01
    • 2021-02-25
    • 2011-11-13
    相关资源
    最近更新 更多