## 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';
7. // Instantiate server
8. $server = new Zend_XmlRpc_Server();
10. // Allow some exceptions to report as fault responses:
11. Zend_XmlRpc_Server_Fault::attachFaultException('My_Exception');
12. Zend_XmlRpc_Server_Fault::attachObserver('My_Fault_Observer');
14. // Get or build dispatch table:
15. if (!Zend_XmlRpc_Server_Cache::get($filename, $server)) {
16. require_once 'Some/Service/Class.php';
17. require_once 'Another/Service/Class.php';
19. // Attach Some_Service_Class in 'some' namespace
20. $server->setClass('Some_Service_Class', 'some');
22. // Attach Another_Service_Class in 'another' namespace; use only static
23. // methods
24. $server->setClass('Another_Service_Class', 'another', false);
26. // Create dispatch table cache file
27. Zend_XmlRpc_Server_Cache::save($filename, $server);
28. }
30. $response = $server->handle();
31. echo $response;

- license: Zend Framework License version 1.0
- copyright: Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)

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

Variable Summary
string $_encoding
array $_methods
null|Zend_XmlRpc_Request $_request
string $_responseClass
array $_table
array $_typeMap
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 ()
null|Zend_XmlRpc_Request getRequest ()
Zend_XmlRpc_Response|Zend_XmlRpc_Fault handle ([Zend_XmlRpc_Request $request = null])
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])
Zend_XmlRpc_Server setRequest (string|Zend_XmlRpc_Request $request)
boolean setResponseClass (string $class)
void _buildDispatchTable ()
void _fixTypes ( $method)
Zend_XmlRpc_Response _handle (Zend_XmlRpc_Request $request)
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 607)

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

Handle an xmlrpc call

- access: public

Zend_XmlRpc_Response|Zend_XmlRpc_Fault handle ([Zend_XmlRpc_Request $request = null])

- Zend_XmlRpc_Request $request: Optional

listMethods (line 630)

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

Display help message for an XMLRPC method

- access: public

string methodHelp (string $method)

- string $method

methodSignature (line 656)

Return a method signature

- access: public

array methodSignature (string $method)

- string $method

multicall (line 692)

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.

- access: public
- see: http://www.xmlrpc.com/discuss/msgReader$1208

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)

- string|Zend_XmlRpc_Request $request

setResponseClass (line 586)

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)

- Zend_Server_Reflection_Function_Abstract $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

Zend_XmlRpc_Response _handle (Zend_XmlRpc_Request $request)

- Zend_XmlRpc_Request $request

Documentation generated on Wed, 21 Feb 2007 11:59:33 -0800 by phpDocumentor 1.3.1