TODO:
- Introspection documentation and method signatures.
EXAMPLE:
$response = Horde_Rpc::request('xmlrpc',
'http://localhost:80/horde/rpc.php',
'contacts.search',
$transport_client,
array(array('jan'), array('localsql'),
array('name', 'email')));
/** * XMLRPC server constructor * * @access private */ public function __construct($request, $params = array()) { parent::__construct($request, $params); $this->_server = xmlrpc_server_create(); foreach ($GLOBALS['registry']->listMethods() as $method) { xmlrpc_server_register_method($this->_server, str_replace('/', '.', $method), array('Horde_Rpc_Xmlrpc', '_dispatcher')); } }
/** * XMLRPC server constructor. */ function __construct($request, $params = array()) { parent::__construct($request, $params); $this->_server = xmlrpc_server_create(); // Register only phpgw services. foreach ($GLOBALS['registry']->listMethods('phpgw') as $method) { $methods = explode('/', $method); array_shift($methods); $method = implode('.', $methods); xmlrpc_server_register_method($this->_server, $method, array('Horde_Rpc_Phpgw', '_dispatcher')); } }
/** * Constructor. * * @param Horde_Controller_Request_Http The request object. * * @param array $params A hash containing configuration parameters: * - server: (Horde_ActiveSync) The ActiveSync server object. * DEFAULT: none, REQUIRED */ public function __construct(Horde_Controller_Request_Http $request, array $params = array()) { parent::__construct($request, $params); // Use the server's getGetVars() method since they might be transmitted // as base64 encoded binary data. $serverVars = $request->getServerVars(); $this->_get = $params['server']->getGetVars(); if ($request->getMethod() == 'POST' && ((empty($this->_get['Cmd']) || empty($this->_get['DeviceId']) || empty($this->_get['DeviceType'])) && empty($serverVars['QUERY_STRING']) && stripos($serverVars['REQUEST_URI'], 'autodiscover/autodiscover.xml') === false)) { $this->_logger->err('Missing required parameters.'); throw new Horde_Rpc_Exception('Your device requested the ActiveSync URL wihtout required parameters.'); } $this->_server = $params['server']; }
/** * SOAP server constructor * * @access private */ public function __construct($request, $params = array()) { parent::__construct($request, $params); if (!empty($params['allowedTypes'])) { $this->_allowedTypes = $params['allowedTypes']; } if (!empty($params['allowedMethods'])) { $this->_allowedMethods = $params['allowedMethods']; } if (!empty($params['serviceName'])) { $this->_serviceName = $params['serviceName']; } $this->_server = new SoapServer(null, array('uri' => (string) Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/rpc.php', true, -1))); $this->_server->addFunction(SOAP_FUNCTIONS_ALL); $this->_server->setClass('Horde_Rpc_Soap_Caller', $params); }
exit; } $params['server'] = $injector->getInstance('Horde_ActiveSyncServer'); $params['requireAuthorization'] = true; break; case 'Soap': $serverVars = $request->getServerVars(); if (!$serverVars['REQUEST_METHOD'] || $serverVars['REQUEST_METHOD'] != 'POST') { $params['requireAuthorization'] = false; $input = Horde_Util::getGet('wsdl') === null ? 'disco' : 'wsdl'; } break; } /* Load the RPC backend based on $serverType. */ try { $server = Horde_Rpc::factory($serverType, $request, $params); } catch (Horde_Rpc_Exception $e) { Horde::log($e, 'ERR'); header('HTTP/1.1 501 Not Implemented'); exit; } // Let the backend check authentication. By default, we look for HTTP // basic authentication against Horde, but backends can override this // as needed. Must reset the authentication argument since we delegate // auth to the RPC server. $registry->setAuthenticationSetting(array_key_exists('requireAuthorization', $params) && $params['requireAuthorization'] === false ? 'none' : 'Authenticate'); try { $server->authorize(); } catch (Horde_Rpc_Exception $e) { Horde::log($e, 'ERR'); header('HTTP/1.0 500 Internal Server Error');
/** * Performs a listQueue API call. * * @throws Horde_Exception * @return array List of queues with IDs as key and information hash as * value. */ protected function _listQueues() { return Horde_Rpc::request('jsonrpc', $this->_params['url'], 'tickets.listSlugs', $this->_http, null)->result; }
<?php /** * @package Rpc */ die("Please configure the URL, username, and password, and then remove this line.\n"); // SOAP endpoint $rpc_endpoint = 'http://example.com/horde/rpc.php'; // SOAP method to call $rpc_method = 'calendar.listCalendars'; // SOAP options, usually username and password $rpc_options = array('login' => '', 'password' => '', 'namespace' => 'urn:horde', 'timeout' => 5, 'allowRedirects' => true, 'maxRedirects' => 3, 'location' => $rpc_endpoint, 'uri' => 'urn:horde', 'exceptions' => true, 'trace' => true); $soap = new SoapClient(null, $rpc_options); $result = Horde_Rpc::request('soap', $GLOBALS['rpc_endpoint'], $GLOBALS['rpc_method'], $soap, array()); var_dump($result);
/** * Constructor. * * @param Horde_Controller_Request_Http $request The request object. * @param array $params A hash containing any additional configuration or * connection parameters. */ public function __construct($request, $params = array()) { parent::__construct($request, $params); $this->_server = $GLOBALS['injector']->getInstance('Horde_Dav_Server'); }
function post_comment($ticket, $log_message) { $http = new Horde_Http_Client($GLOBALS['rpc_options']); try { $result = Horde_Rpc::request('xmlrpc', $GLOBALS['rpc_endpoint'], $GLOBALS['rpc_method'], $http, array((int) $ticket, $log_message)); } catch (Horde_Http_Exception $e) { abort($e->getMessage()); } catch (Horde_Rpc_Exception $e) { // Ignore } return true; }
<?php /** * @package Rpc */ die("Please configure the URL, username, and password, and then remove this line.\n"); // XML-RPC endpoint $rpc_endpoint = 'http://example.com/horde/rpc.php'; // XML-RPC method to call $rpc_method = 'calendar.listCalendars'; // XML-RPC options, usually username and password $rpc_options = array('request.username' => '', 'request.password' => ''); $http_client = new Horde_Http_Client($rpc_options); $result = Horde_Rpc::request('xmlrpc', $GLOBALS['rpc_endpoint'], $GLOBALS['rpc_method'], $GLOBALS['http_client'], array()); var_dump($result);