Zend Rest 客户端问题
我有下面的代码
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]:^
请帮我解决这个问题
i have the codes below
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();
}
}
and
<?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();
}
}
and the class and method as
<?php
class Someclass
{
/**
* Say Hello
*
* @param string $who
* @return string
*/
function sayHello($who)
{
return "Hello $who";
}
}
but while calling this
i got an error
Message: REST Response Error: simplexml_load_string()
[function.simplexml-load-string]: ^
pls help me to solve this issue
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(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。休息.服务器.html
Sounds like you're not returning an XML response from your REST request. SimpleXML only fails when it doesn't get valid XML as a parameter.
Make sure that your REST server is actually employing Zend_REST_Server, which outputs the return value of a function into an XML response.
For more info on how Zend_Rest_Client works: http://framework.zend.com/manual/en/zend.rest.client.html
For more info on Zend_Rest_Server:
http://framework.zend.com/manual/en/zend.rest.server.html