An XML-RPC server implementation

Example: require_once 'Zend/XmlRpc/Server.php'; require_once 'Zend/XmlRpc/Server/Cache.php'; require_once 'Zend/XmlRpc/Server/Fault.php'; require_once 'My/Exception.php'; require_once 'My/Fault/Observer.php';

// Instantiate server $server = new Zend_XmlRpc_Server();

// Allow some exceptions to report as fault responses: Zend_XmlRpc_Server_Fault::attachFaultException('My_Exception'); Zend_XmlRpc_Server_Fault::attachObserver('My_Fault_Observer');

// Get or build dispatch table: if (!Zend_XmlRpc_Server_Cache::get($filename, $server)) { require_once 'Some/Service/Class.php'; require_once 'Another/Service/Class.php';

// Attach Some_Service_Class in 'some' namespace
$server->setClass('Some_Service_Class', 'some');

// Attach Another_Service_Class in 'another' namespace
$server->setClass('Another_Service_Class', 'another');

// Create dispatch table cache file
Zend_XmlRpc_Server_Cache::save($filename, $server);

}

$response = $server->handle(); echo $response;

category Zend
package Zend_XmlRpc
subpackage Server
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License
inherited_from \Zend_Server_Abstract

 Methods

Proxy calls to system object

__call(string $method, array $params) : mixed

Parameters

$method

string

$params

array

Exceptions

\Zend_XmlRpc_Server_Exception

Returns

mixed

Constructor

__construct() : void

Creates system.* methods.

inherited_from \Zend_Server_Abstract::__construct()

Constructor

__construct() : void
Inherited

Setup server description

Attach a callback as an XMLRPC method

addFunction(string|array $function, string $namespace = '') : void

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.

Parameters

$function

stringarray

Valid callback

$namespace

string

Optional namespace prefix

Exceptions

\Zend_XmlRpc_Server_Exception

Raise an xmlrpc server fault

fault(string|\Exception $fault = null, integer $code = 404) : \Zend_XmlRpc_Server_Fault

Parameters

$fault

string\Exception

$code

integer

Returns

\Zend_XmlRpc_Server_Fault

Retrieve dispatch table

getDispatchTable() : array

Returns

array

Retrieve current encoding

getEncoding() : string

Returns

string

Returns a list of registered methods

getFunctions() : array

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

inherited_from \Zend_Server_Abstract::getFunctions()

Returns

array

Returns a list of registered methods

getFunctions() : \Zend_Server_Definition
Inherited

Returns an array of method definitions.

inherited_from \Zend_Server_Interface::getFunctions()

Returns

\Zend_Server_Definition

Return currently registered request object

getRequest() : null | \Zend_XmlRpc_Request

Returns

null\Zend_XmlRpc_Request

Retrieve current response class

getResponseClass() : string

Returns

string

Retrieve system object

getSystem() : \Zend_XmlRpc_Server_System

Returns

\Zend_XmlRpc_Server_System

Handle an xmlrpc call

handle(\Zend_XmlRpc_Request $request = false) : \Zend_XmlRpc_Response | \Zend_XmlRpc_Fault

Parameters

$request

\Zend_XmlRpc_Request

Optional

Returns

\Zend_XmlRpc_Response\Zend_XmlRpc_Fault

Load methods as returned from {@link getFunctions}

loadFunctions(array|\Zend_Server_Definition $definition) : void

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

Parameters

$definition

array\Zend_Server_Definition

Exceptions

\Zend_XmlRpc_Server_Exception on invalid input

Lowercase a string

lowerCase($value, string $key) : string
InheritedStatic

Lowercase's a string by reference

deprecated

Parameters

$value

$key

string

Returns

stringLower cased string

Send arguments to all methods?

sendArgumentsToAllMethods($flag = null

If setClass() is used to add classes to the server, this flag defined how to handle arguments. If set to true, all methods including constructor will receive the arguments. If set to false, only constructor will receive the arguments

Parameters

$flag

Attach class methods as XMLRPC method handlers

setClass(string|object $class, string $namespace = '', mixed $argv = null) : void

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

Parameters

$class

stringobject

$namespace

string

Optional

$argv

mixed

Optional arguments to pass to methods

Exceptions

\Zend_XmlRpc_Server_Exception on invalid input

Set encoding

setEncoding(string $encoding) : \Zend_XmlRpc_Server

Parameters

$encoding

string

Returns

\Zend_XmlRpc_Server

Do nothing; persistence is handled via {@link Zend_XmlRpc_Server_Cache}

setPersistence(mixed $mode) : void

Parameters

$mode

mixed

Set the request object

setRequest(string|\Zend_XmlRpc_Request $request) : \Zend_XmlRpc_Server

Parameters

$request

string\Zend_XmlRpc_Request

Exceptions

\Zend_XmlRpc_Server_Exception on invalid request class or object

Returns

\Zend_XmlRpc_Server

Set the class to use for the response

setResponseClass(string $class) : boolean

Parameters

$class

string

Returns

booleanTrue if class was set, false if not

Build callback for method signature

_buildCallback(\Zend_Server_Reflection_Function_Abstract $reflection) : \Zend_Server_Method_Callback
Inherited

Parameters

$reflection

\Zend_Server_Reflection_Function_Abstract

Returns

\Zend_Server_Method_Callback

Build a method signature

_buildSignature(\Zend_Server_Reflection_Function_Abstract $reflection, null|string|object $class = null) : \Zend_Server_Method_Definition
Inherited

Parameters

$reflection

\Zend_Server_Reflection_Function_Abstract

$class

nullstringobject

Exceptions

\Zend_Server_Exception on duplicate entry

Returns

\Zend_Server_Method_Definition

Dispatch method

_dispatch(\Zend_Server_Method_Definition $invocable, array $params) : mixed
Inherited

Parameters

$invocable

\Zend_Server_Method_Definition

$params

array

Returns

mixed

Map PHP type to XML-RPC type

_fixType(string $type) : string
inherited_from \Zend_Server_Abstract::_fixType()

Parameters

$type

string

Returns

string

Map PHP type to protocol type

_fixType(string $type) : string
Inherited

Parameters

$type

string

Returns

string

Handle an xmlrpc call (actual work)

_handle(\Zend_XmlRpc_Request $request) : \Zend_XmlRpc_Response

Parameters

$request

\Zend_XmlRpc_Request

Exceptions

\Zend_XmlRpcServer_Exception\Exception Zend_XmlRpcServer_Exceptions are thrown for internal errors; otherwise, any other exception may be thrown by the callback

Returns

\Zend_XmlRpc_Response

Register system methods with the server

_registerSystemMethods() : void

 Properties

 

Character encoding

$_encoding : string

Default

'UTF-8'
 

Flag; whether or not overwriting existing methods is allowed

$_overwriteExistingMethods : boolean

Default

false
 

Request processed

$_request : null | \Zend_XmlRpc_Request

Default

null
 

Class to use for responses; defaults to {@link Zend_XmlRpc_Response_Http}

$_responseClass : string

Default

'Zend_XmlRpc_Response_Http'
 

Send arguments to all methods or just constructor?

$_sendArgumentsToAllMethods : boolean

Default

true
 

Dispatch table of name => method pairs

$_table : \Zend_Server_Definition

Default

inherited_from \Zend_Server_Abstract::_table
 

$_table

$_table : \Zend_Server_Definition

Default

 

PHP types => XML-RPC types

$_typeMap : array

Default

array('i4' => 'i4', 'int' => 'int', 'integer' => 'int', 'Zend_Crypt_Math_BigInteger' => 'i8', 'i8' => 'i8', 'ex:i8' => 'i8', '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', 'Zend_Date' => 'dateTime.iso8601', 'DateTime' => 'dateTime.iso8601', 'array' => 'array', 'struct' => 'struct', 'null' => 'nil', 'nil' => 'nil', 'ex:nil' => 'nil', 'void' => 'void', 'mixed' => 'struct')
 

List of PHP magic methods (lowercased)

$magic_methods : array

Default

array('__call', '__clone', '__construct', '__destruct', '__get', '__isset', '__set', '__set_state', '__sleep', '__tostring', '__unset', '__wakeup')
Static
deprecated