2009-08-17 135 views
0

我想構建一個基本的應用程序,2個PHP文件,一個使用Zend_Rest_Server,另一個使用Zend_Rest_Client。Zend_Rest_Server不調用類方法

這裏是服務器代碼:

class test1 { 


    public function test() { 
     return "mytest"; 
    } 


} 

include_once ("common.php"); 

set_include_path('.' . PATH_SEPARATOR . '..\..\library/' . get_include_path()); 
require_once 'Zend/Loader.php'; 
Zend_Loader::registerAutoload(); 

$server = new Zend_Rest_Server(); 

$server->setClass('test1'); 
$server->handle(); 

客戶端代碼是

set_include_path('.' . PATH_SEPARATOR . '.\library/' . get_include_path()); 
require_once 'Zend/Loader.php'; 
Zend_Loader::registerAutoload(); 

$client = new Zend_Rest_Client('http://localhost/dbuilder/db/jpuzzle.php'); 

$client->arg("test"); 
echo $client->get(); 

當我運行命令行界面的客戶端應用程序ws.php我得到這個消息:

Zend_Rest_Client_Result_Exception: REST Response Error: An error occured while p arsing the REST response with simplexml. in C:\Program Files\VertrigoServ\www\li brary\Zend\Rest\Client\Result.php on line 67

什麼可能是它不運行的原因以及它如何被調試?

回答

0

實際的問題不是在服務中,而是在不贊成使用自動載入。

我更換

require_once 'Zend/Loader.php'; 
Zend_Loader::registerAutoload(); 

require_once ‘Zend/Loader/Autoloader.php’; 
$autoloader = Zend_Loader_Autoloader::getInstance(); 
$autoloader->setFallbackAutoloader(true); 

,並得到了Web服務的工作。