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-2010 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-2010 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
35 * @var Zend_XmlRpc_Server
42 * @param Zend_XmlRpc_Server $server
45 public function __construct(Zend_XmlRpc_Server
$server)
47 $this->_server
= $server;
51 * List all available XMLRPC methods
53 * Returns an array of methods.
57 public function listMethods()
59 $table = $this->_server
->getDispatchTable()->getMethods();
60 return array_keys($table);
64 * Display help message for an XMLRPC method
66 * @param string $method
69 public function methodHelp($method)
71 $table = $this->_server
->getDispatchTable();
72 if (!$table->hasMethod($method)) {
73 require_once 'Zend/XmlRpc/Server/Exception.php';
74 throw new Zend_XmlRpc_Server_Exception('Method "' . $method . '" does not exist', 640);
77 return $table->getMethod($method)->getMethodHelp();
81 * Return a method signature
83 * @param string $method
86 public function methodSignature($method)
88 $table = $this->_server
->getDispatchTable();
89 if (!$table->hasMethod($method)) {
90 require_once 'Zend/XmlRpc/Server/Exception.php';
91 throw new Zend_XmlRpc_Server_Exception('Method "' . $method . '" does not exist', 640);
93 $method = $table->getMethod($method)->toArray();
94 return $method['prototypes'];
98 * Multicall - boxcar feature of XML-RPC for calling multiple methods
99 * in a single request.
101 * Expects a an array of structs representing method calls, each element
106 * Returns an array of responses, one for each method called, with the value
107 * returned by the method. If an error occurs for a given method, returns a
108 * struct with a fault response.
110 * @see http://www.xmlrpc.com/discuss/msgReader$1208
111 * @param array $methods
114 public function multicall($methods)
116 $responses = array();
117 foreach ($methods as $method) {
119 if (!is_array($method)) {
120 $fault = $this->_server
->fault('system.multicall expects each method to be a struct', 601);
121 } elseif (!isset($method['methodName'])) {
122 $fault = $this->_server
->fault('Missing methodName: ' . var_export($methods, 1), 602);
123 } elseif (!isset($method['params'])) {
124 $fault = $this->_server
->fault('Missing params', 603);
125 } elseif (!is_array($method['params'])) {
126 $fault = $this->_server
->fault('Params must be an array', 604);
128 if ('system.multicall' == $method['methodName']) {
129 // don't allow recursive calls to multicall
130 $fault = $this->_server
->fault('Recursive system.multicall forbidden', 605);
136 $request = new Zend_XmlRpc_Request();
137 $request->setMethod($method['methodName']);
138 $request->setParams($method['params']);
139 $response = $this->_server
->handle($request);
140 if ($response instanceof Zend_XmlRpc_Fault
141 ||
$response->isFault()
145 $responses[] = $response->getReturnValue();
147 } catch (Exception
$e) {
148 $fault = $this->_server
->fault($e);
153 $responses[] = array(
154 'faultCode' => $fault->getCode(),
155 'faultString' => $fault->getMessage()