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; use only static
  22.      // methods
  23.           $server->setClass('Another_Service_Class''another'false);
  24.  
  25.      // Create dispatch table cache file
  26.           Zend_XmlRpc_Server_Cache::save($filename$server);
  27.  }
  28.  
  29.  $response $server->handle();
  30.  echo $response;

Located in /Zend/XmlRpc/Server.php (line 121)


	
			
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 127)

Character encoding

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

Array of dispatchables

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

Request processed

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

Class to use for responses; defaults to Zend_XmlRpc_Response_Http

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

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 157)

PHP types => XML-RPC types

  • access: protected
Methods
Constructor __construct (line 189)

Constructor

Creates system.* methods.

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

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.

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

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 292)

Retrieve current encoding

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

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 444)

Return currently registered request object

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

Handle an xmlrpc call

  • access: public
listMethods (line 629)

List all available XMLRPC methods

Returns an array of methods.

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

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().

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

Display help message for an XMLRPC method

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

Return a method signature

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

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 398)

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.

  • access: public
  • throws: Zend_XmlRpc_Server_Exception on invalid input
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 281)

Set encoding

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

Do nothing; persistence is handled via Zend_XmlRpc_Server_Cache

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

Set the request object

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

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 237)

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 215)

Map PHP parameter types to XML-RPC types

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

Handle an xmlrpc call (actual work)

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

Documentation generated on Thu, 18 Jan 2007 09:59:06 -0800 by phpDocumentor 1.3.1