/** * This is the XML-RPC server routine * * @access public * @return void */ public function run() { Yii::import('application.helpers.remotecontrol.*'); $oHandler = new remotecontrol_handle($this->controller); $RPCType = Yii::app()->getConfig("RPCInterface"); if (Yii::app()->getRequest()->isPostRequest) { if ($RPCType == 'xml') { $cur_path = get_include_path(); set_include_path($cur_path . PATH_SEPARATOR . APPPATH . 'helpers'); // Yii::import was causing problems for some odd reason require_once 'Zend/XmlRpc/Server.php'; require_once 'Zend/XmlRpc/Server/Exception.php'; require_once 'Zend/XmlRpc/Value/Exception.php'; $this->xmlrpc = new Zend_XmlRpc_Server(); $this->xmlrpc->sendArgumentsToAllMethods(false); Yii::import('application.libraries.LSZend_XmlRpc_Response_Http'); $this->xmlrpc->setResponseClass('LSZend_XmlRpc_Response_Http'); $this->xmlrpc->setClass($oHandler); $result = $this->xmlrpc->handle(); if ($result instanceof LSZend_XmlRpc_Response_Http) { $result->printXml(); } else { // a Zend_XmlRpc_Server_Fault with exception message from XMLRPC echo $result; } } elseif ($RPCType == 'json') { Yii::app()->loadLibrary('LSjsonRPCServer'); if (!isset($_SERVER['CONTENT_TYPE'])) { $serverContentType = explode(';', $_SERVER['HTTP_CONTENT_TYPE']); $_SERVER['CONTENT_TYPE'] = reset($serverContentType); } LSjsonRPCServer::handle($oHandler); } foreach (App()->log->routes as $route) { $route->enabled = $route->enabled && !$route instanceof CWebLogRoute; } exit; } else { // Disabled output of API methods for now if (Yii::app()->getConfig("rpc_publish_api") == true && in_array($RPCType, array('xml', 'json'))) { $reflector = new ReflectionObject($oHandler); foreach ($reflector->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { /* @var $method ReflectionMethod */ if (substr($method->getName(), 0, 1) !== '_') { $list[$method->getName()] = array('description' => str_replace(array("\r", "\r\n", "\n"), "<br/>", $method->getDocComment()), 'parameters' => $method->getParameters()); } } ksort($list); $aData['method'] = $RPCType; $aData['list'] = $list; $aData['display']['menu_bars'] = false; // Hide normal menu bar $this->_renderWrappedTemplate('remotecontrol', array('index_view'), $aData); } } }
/** * This is the XML-RPC server routine * * @access public * @return void */ public function run() { $RPCType = Yii::app()->getConfig("RPCInterface"); if ($RPCType == 'xml') { $cur_path = get_include_path(); set_include_path($cur_path . PATH_SEPARATOR . APPPATH . 'helpers'); // Yii::import was causing problems for some odd reason require_once 'Zend/XmlRpc/Server.php'; require_once 'Zend/XmlRpc/Server/Exception.php'; require_once 'Zend/XmlRpc/Value/Exception.php'; $this->xmlrpc = new Zend_XmlRpc_Server(); $this->xmlrpc->sendArgumentsToAllMethods(false); $this->xmlrpc->setClass('remotecontrol_handle', '', $this->controller); echo $this->xmlrpc->handle(); } elseif ($RPCType == 'json') { Yii::app()->loadLibrary('jsonRPCServer'); $oHandler = new remotecontrol_handle($this->controller); jsonRPCServer::handle($oHandler); } exit; }
public function testSettingClassWithArgumentsOnlyPassingToConstructor() { $this->_server->setClass('Zend_XmlRpc_Server_testClass', 'test', 'a1', 'a2'); $this->_server->sendArgumentsToAllMethods(false); $this->assertFalse($this->_server->sendArgumentsToAllMethods()); $request = new Zend_XmlRpc_Request(); $request->setMethod('test.test4'); $request->setParams(array('foo')); $response = $this->_server->handle($request); $this->assertFalse($response instanceof Zend_XmlRpc_Fault); $this->assertSame(array('test1' => 'a1', 'test2' => 'a2', 'arg' => array('foo')), $response->getReturnValue()); }
/** * This is the XML-RPC server routine * * @access public * @return void */ public function run() { $oHandler = new remotecontrol_handle($this->controller); $RPCType = Yii::app()->getConfig("RPCInterface"); if (Yii::app()->getRequest()->isPostRequest) { if ($RPCType == 'xml') { $cur_path = get_include_path(); set_include_path($cur_path . PATH_SEPARATOR . APPPATH . 'helpers'); // Yii::import was causing problems for some odd reason require_once 'Zend/XmlRpc/Server.php'; require_once 'Zend/XmlRpc/Server/Exception.php'; require_once 'Zend/XmlRpc/Value/Exception.php'; $this->xmlrpc = new Zend_XmlRpc_Server(); $this->xmlrpc->sendArgumentsToAllMethods(false); $this->xmlrpc->setClass($oHandler); echo $this->xmlrpc->handle(); } elseif ($RPCType == 'json') { Yii::app()->loadLibrary('jsonRPCServer'); jsonRPCServer::handle($oHandler); } exit; } else { // Disabled output of API methods for now if (1 == 2 && in_array($RPCType, array('xml', 'json'))) { $reflector = new ReflectionObject($oHandler); foreach ($reflector->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { /* @var $method ReflectionMethod */ if (substr($method->getName(), 0, 1) !== '_') { $list[$method->getName()] = array('description' => str_replace(array("\r", "\r\n", "\n"), "<br/>", $method->getDocComment()), 'parameters' => $method->getParameters()); } } ksort($list); $aData['method'] = $RPCType; $aData['list'] = $list; $aData['display']['menu_bars'] = false; // Hide normal menu bar $this->_renderWrappedTemplate('remotecontrol', array('index_view'), $aData); } } }