Class Zend_XmlRpc_Server

Description

An XML-RPC server implementation

Example:

  1.  require_once 'Zend/XmlRpc/Server.php';
  2.  require_once 'Zend/XmlRpc/Server/Cache.php';
  3.  require_once 'Zend/XmlRpc/Server/Fault.php';
  4.  require_once 'My/Exception.php';
  5.  require_once 'My/Fault/Observer.php';
  6.  
  7.  // Instantiate server
  8.  $server new Zend_XmlRpc_Server();
  9.  
  10.  // Allow some exceptions to report as fault responses:
  11.  Zend_XmlRpc_Server_Fault::attachObserver('My_Fault_Observer');
  12.  
  13.  // Get or build dispatch table:
  14.  if (!Zend_XmlRpc_Server_Cache::get($filename$server)) {
  15.      require_once 'Some/Service/Class.php';
  16.      require_once 'Another/Service/Class.php';
  17.  
  18.      // Attach Some_Service_Class in 'some' namespace
  19.      $server->setClass('Some_Service_Class''some');
  20.  
  21.      // Attach Another_Service_Class in 'another' namespace
  22.      $server->setClass('Another_Service_Class''another');
  23.  
  24.      // Create dispatch table cache file
  25.      Zend_XmlRpc_Server_Cache::save($filename$server);
  26.  }
  27.  
  28.  $response $server->handle();
  29.  echo $response;

Located in /XmlRpc/Server.php (line 115)


	
			
Variable Summary
Method Summary
 void __construct ()
 void addFunction (string|array $function, [string $namespace = ''])
 Zend_XmlRpc_Server_Fault fault (string|Exception $fault, [int $code = 404])
 string getEncoding ()
 array getFunctions ()
 array listMethods ()
 void loadFunctions (array $array)
 string methodHelp (string $method)
 array methodSignature (string $method)
 array multicall (array $methods)
 void setClass (string|object  $class, [string $namespace = ''], [mixed $argv = null])
 Zend_XmlRpc_Server setEncoding (string $encoding)
 void setPersistence ([mixed $class = null])
 boolean setResponseClass (string $class)
 void _fixTypes ( $method)
Variables
string $_encoding = 'UTF-8' (line 121)

Character encoding

  • access: protected
array $_methods = array() (line 127)

Array of dispatchables

  • access: protected
null|Zend_XmlRpc_Request $_request = null (line 133)

Request processed

  • access: protected
string $_responseClass = 'Zend_XmlRpc_Response_Http' (line 139)

Class to use for responses; defaults to Zend_XmlRpc_Response_Http

  • access: protected
array $_table = array() (line 145)

Dispatch table of name => method pairs

  • access: protected
array $_typeMap = array(
'i4' => 'i4',
'int' => 'int',
'integer' => 'int',
'double' => 'double',
'float' => 'double',
'real' => 'double',
'boolean' => 'boolean',
'bool' => 'boolean',
'true' => 'boolean',
'false' => 'boolean',
'string' => 'string',
'str' => 'string',
'base64' => 'base64',
'dateTime.iso8601' => 'dateTime.iso8601',
'date' => 'dateTime.iso8601',
'time' => 'dateTime.iso8601',
'time' => 'dateTime.iso8601',
'array' => 'array',
'struct' => 'struct',
'null' => 'void',
'void' => 'void',
'mixed' => 'struct'
)
(line 151)

PHP types => XML-RPC types

  • access: protected
Methods
Constructor __construct (line 183)

Constructor

Creates system.* methods.

  • access: public
void __construct ()
addFunction (line 307)

Attach a callback as an XMLRPC method

Attaches a callback as an XMLRPC method, prefixing the XMLRPC method name with $namespace, if provided. Reflection is done on the callback's docblock to create the methodHelp for the XMLRPC method.

Additional arguments to pass to the function at dispatch may be passed; any arguments following the namespace will be aggregated and passed at dispatch time.

  • throws: Zend_XmlRpc_Server_Exception
  • access: public
void addFunction (string|array $function, [string $namespace = ''])
  • string|array $function: Valid callback
  • string $namespace: Optional namespace prefix
fault (line 450)

Raise an xmlrpc server fault

  • access: public
Zend_XmlRpc_Server_Fault fault (string|Exception $fault, [int $code = 404])
  • string|Exception $fault
  • int $code
getEncoding (line 286)

Retrieve current encoding

  • access: public
string getEncoding ()
getFunctions (line 601)

Returns a list of registered methods

Returns an array of dispatchables (Zend_Server_Reflection_Function, _Method, and _Class items).

  • access: public
array getFunctions ()
getRequest (line 438)

Return currently registered request object

  • access: public
null|Zend_XmlRpc_Request getRequest ()
handle (line 547)

Handle an xmlrpc call

  • access: public
listMethods (line 624)

List all available XMLRPC methods

Returns an array of methods.

  • access: public
array listMethods ()
loadFunctions (line 340)

Load methods as returned from getFunctions

Typically, you will not use this method; it will be called using the results pulled from Zend_XmlRpc_Server_Cache::get().

  • throws: Zend_XmlRpc_Server_Exception on invalid input
  • access: public
void loadFunctions (array $array)
  • array $array
methodHelp (line 635)

Display help message for an XMLRPC method

  • access: public
string methodHelp (string $method)
  • string $method
methodSignature (line 650)

Return a method signature

  • access: public
array methodSignature (string $method)
  • string $method
multicall (line 686)

Multicall - boxcar feature of XML-RPC for calling multiple methods in a single request.

Expects a an array of structs representing method calls, each element having the keys:

  • methodName
  • params
Returns an array of responses, one for each method called, with the value returned by the method. If an error occurs for a given method, returns a struct with a fault response.

array multicall (array $methods)
  • array $methods
setClass (line 392)

Attach class methods as XMLRPC method handlers

$class may be either a class name or an object. Reflection is done on the class or object to determine the available public methods, and each is attached to the server as an available method; if a $namespace has been provided, that namespace is used to prefix the XMLRPC method names.

Any additional arguments beyond $namespace will be passed to a method at invocation.

  • throws: Zend_XmlRpc_Server_Exception on invalid input
  • access: public
void setClass (string|object  $class, [string $namespace = ''], [mixed $argv = null])
  • string|object $class
  • string $namespace: Optional
  • mixed $argv: Optional arguments to pass to methods
setEncoding (line 275)

Set encoding

  • access: public
Zend_XmlRpc_Server setEncoding (string $encoding)
  • string $encoding
setPersistence (line 371)

Do nothing; persistence is handled via Zend_XmlRpc_Server_Cache

  • access: public
void setPersistence ([mixed $class = null])
  • mixed $class
setRequest (line 417)

Set the request object

  • throws: Zend_XmlRpc_Server_Exception on invalid request class or object
  • access: public
Zend_XmlRpc_Server setRequest (string|Zend_XmlRpc_Request $request)
setResponseClass (line 580)

Set the class to use for the response

  • return: True if class was set, false if not
  • access: public
boolean setResponseClass (string $class)
  • string $class
_buildDispatchTable (line 231)

Re/Build the dispatch table

The dispatch table consists of a an array of method name => Zend_Server_Reflection_Function_Abstract pairs

  • access: protected
void _buildDispatchTable ()
_fixTypes (line 209)

Map PHP parameter types to XML-RPC types

  • access: protected
void _fixTypes ( $method)
_handle (line 469)

Handle an xmlrpc call (actual work)

  • throws: Zend_XmlRpcServer_Exception|Exception Zend_XmlRpcServer_Exceptions are thrown for internal errors; otherwise, any other exception may be thrown by the callback
  • access: protected

Documentation generated on Sun, 27 May 2007 23:27:31 -0700 by phpDocumentor 1.3.2