Docs For Class Zend_XmlRpc_Server

## 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';
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-2006 Zend Technologies USA Inc. (http://www.zend.com)

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

Variable Summary
array $_methods
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])
array getFunctions ()
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])
void setPersistence ([mixed $class = null])
boolean setResponseClass (string $class)
void _buildDispatchTable ()
void _fixTypes ( $method)
Zend_XmlRpc_Response _handle (Zend_XmlRpc_Request $request)
Variables
array $_methods = array() (line 127)

Array of dispatchables

- access: protected

string $_responseClass = 'Zend_XmlRpc_Response_Http' (line 133)

Class to use for responses; defaults to Zend_XmlRpc_Response_Http

- access: protected

array $_table = array() (line 139)

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

PHP types => XML-RPC types

- access: protected

Methods
Constructor __construct (line 177)

Constructor

Sets encoding to UTF-8 and creates system.* methods.

- access: public

void __construct ()
addFunction (line 282)

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

Raise an xmlrpc server fault

- access: public

Zend_XmlRpc_Server_Fault fault (string|Exception $fault, [int $code = 404])

- string|Exception $fault
- int $code

getFunctions (line 536)

Returns a list of registered methods

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

- access: public

array getFunctions ()
handle (line 488)

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

List all available XMLRPC methods

Returns an array of methods.

- access: public

array listMethods ()
loadFunctions (line 315)

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

Display help message for an XMLRPC method

- access: public

string methodHelp (string $method)

- string $method

methodSignature (line 585)

Return a method signature

- access: public

array methodSignature (string $method)

- string $method

multicall (line 621)

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

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

setPersistence (line 346)

Do nothing; persistence is handled via Zend_XmlRpc_Server_Cache

- access: public

void setPersistence ([mixed $class = null])

- mixed $class

setResponseClass (line 515)

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

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

Map PHP parameter types to XML-RPC types

- access: protected

void _fixTypes ( $method)

- Zend_Server_Reflection_Function_Abstract $method

_handle (line 411)

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 Sun, 29 Oct 2006 21:28:02 -0600 by phpDocumentor 1.3.0RC6