ZF-10847: ZEND + Restful service



Firstly sorry for my poor english I'm trying out RESTful services with Zend Framework and I encouter a problem when I run my client script

message = REST Response Error: simplexml_load_string() [function.simplexml-load-string]: ^

My best thanks if you could help me

my scripts : a)the service

<?php require_once 'Zend/Controller/Action.php'; class IndexController extends Zend_Controller_Action { // Action REST service public function restAction() { require_once('Zend/Rest/Server.php'); $server = new Zend_Rest_Server(); $server->setClass('CustomTestClass'); $server->handle(); exit; } }class CustomTestClass { /** * say Hello * * @param string $name * @return string */ public function sayHello($name) { return "hello".$name; } } ?> b)the client

<?php require_once 'Zend/Controller/Action.php'; class ClientController extends Zend_Controller_Action { // Action REST client + LOG public function indexAction() { try { $logger = new Zend_Log(); require_once('/Zend/Rest/Client.php'); $client = new Zend_Rest_Client('…'); $toto='fanfan'; $result=$client->sayHello($toto)->get(); if ($result->isSuccess()) { $this->view->result = $result; } } catch (Zend_Exception $e) { $redacteur = new Zend_Log_Writer_Stream("log-rest"); $logger->addWriter($redacteur); $logger->log("resultat service rest :".$prob."message :". $e->getMessage() ,Zend_Log::INFO); } } } ?>Some more informations : When I run the URL view-source:http://localhost/webs/test-rest/… into Chrome , I can see no problems I use zend framework 1.1 I think that it have a problem to find the method sayHello My very best regards



As there is no ZF version 1.1, can you please copy and paste the value of Zend_Version::VERSION, please? We have both 1.10 and 1.11, but no 1.1.

Second, is SimpleXML enabled on your PHP installation? If so, can you cut and paste the XML generated by the service, and pass it into simplexml_load_string() to see if there are errors that occur? If so, we'll know then if there are issues with the XML generation of the REST server.

Third, I'd recommend not using Zend_Rest_Server, and instead using Zend_Rest_Route + Zend_Rest_Controller in your MVC. It's a much cleaner, more RESTful way to do REST services.