7
* This source file is subject to the new BSD license that is bundled
8
* with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://framework.zend.com/license/new-bsd
11
* If you did not receive a copy of the license and are unable to
12
* obtain it through the world-wide-web, please send an email
13
* to license@zend.com so we can send you a copy immediately.
16
* @package Zend_XmlRpc
18
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
19
* @license http://framework.zend.com/license/new-bsd New BSD License
24
* XML-RPC system.* methods
27
* @package Zend_XmlRpc
29
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
30
* @license http://framework.zend.com/license/new-bsd New BSD License
32
class Zend_XmlRpc_Server_System
37
* @param Zend_XmlRpc_Server $server
40
public function __construct(Zend_XmlRpc_Server $server)
42
$this->_server = $server;
46
* List all available XMLRPC methods
48
* Returns an array of methods.
52
public function listMethods()
54
$table = $this->_server->getDispatchTable()->getMethods();
55
return array_keys($table);
59
* Display help message for an XMLRPC method
61
* @param string $method
64
public function methodHelp($method)
66
$table = $this->_server->getDispatchTable();
67
if (!$table->hasMethod($method)) {
68
throw new Zend_Server_Exception('Method "' . $method . '"does not exist', 640);
71
return $table->getMethod($method)->getMethodHelp();
75
* Return a method signature
77
* @param string $method
80
public function methodSignature($method)
82
$table = $this->_server->getDispatchTable();
83
if (!$table->hasMethod($method)) {
84
throw new Zend_Server_Exception('Method "' . $method . '"does not exist', 640);
86
$method = $table->getMethod($method)->toArray();
87
return $method['prototypes'];
91
* Multicall - boxcar feature of XML-RPC for calling multiple methods
92
* in a single request.
94
* Expects a an array of structs representing method calls, each element
99
* Returns an array of responses, one for each method called, with the value
100
* returned by the method. If an error occurs for a given method, returns a
101
* struct with a fault response.
103
* @see http://www.xmlrpc.com/discuss/msgReader$1208
104
* @param array $methods
107
public function multicall($methods)
109
$responses = array();
110
foreach ($methods as $method) {
112
if (!is_array($method)) {
113
$fault = $this->_server->fault('system.multicall expects each method to be a struct', 601);
114
} elseif (!isset($method['methodName'])) {
115
$fault = $this->_server->fault('Missing methodName: ' . var_export($methods, 1), 602);
116
} elseif (!isset($method['params'])) {
117
$fault = $this->_server->fault('Missing params', 603);
118
} elseif (!is_array($method['params'])) {
119
$fault = $this->_server->fault('Params must be an array', 604);
121
if ('system.multicall' == $method['methodName']) {
122
// don't allow recursive calls to multicall
123
$fault = $this->_server->fault('Recursive system.multicall forbidden', 605);
129
$request = new Zend_XmlRpc_Request();
130
$request->setMethod($method['methodName']);
131
$request->setParams($method['params']);
132
$response = $this->_server->handle($request);
133
$responses[] = $response->getReturnValue();
134
} catch (Exception $e) {
135
$fault = $this->_server->fault($e);
140
$responses[] = array(
141
'faultCode' => $fault->getCode(),
142
'faultString' => $fault->getMessage()