Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
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;
string $_encoding = 'UTF-8'Character encoding
Detailsnull|Zend_XmlRpc_Request $_request = 'null'Request processed
Detailsstring $_responseClass = 'Zend_XmlRpc_Response_Http'Class to use for responses; defaults to {@link Zend_XmlRpc_Response_Http}
Detailsbool $_sendArgumentsToAllMethods = 'true'Send arguments to all methods or just constructor?
DetailsZend_Server_Definition $_table = ''Dispatch table of name => method pairs
Detailsarray $_typeMap = 'array'PHP types => XML-RPC types
Details__call(
string $method, array $params
)
:
mixedProxy calls to system object
Details__construct(
)
:
voidConstructor
Creates system.* methods.
Details_fixType(
string $type
)
:
stringMap PHP type to XML-RPC type
Details_handle(
Zend_XmlRpc_Request $request
)
:
Zend_XmlRpc_ResponseHandle an xmlrpc call (actual work)
Details_registerSystemMethods(
)
:
voidRegister system methods with the server
DetailsaddFunction(
string|array $function, string $namespace
)
:
voidAttach 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.
Detailsfault(
string|Exception $fault
=
null, int $code
=
404
)
:
Zend_XmlRpc_Server_FaultRaise an xmlrpc server fault
DetailsgetDispatchTable(
)
:
arrayRetrieve dispatch table
DetailsgetEncoding(
)
:
stringRetrieve current encoding
DetailsgetFunctions(
)
:
arrayReturns a list of registered methods
Returns an array of dispatchables (Zend_Server_Reflection_Function, _Method, and _Class items).
DetailsgetRequest(
)
:
null|Zend_XmlRpc_RequestReturn currently registered request object
DetailsgetResponseClass(
)
:
stringRetrieve current response class
DetailsgetSystem(
)
:
Zend_XmlRpc_Server_SystemRetrieve system object
Detailshandle(
Zend_XmlRpc_Request $request
=
false
)
:
Zend_XmlRpc_Response|Zend_XmlRpc_FaultHandle an xmlrpc call
DetailsloadFunctions(
array|Zend_Server_Definition $definition
)
:
voidLoad methods as returned from {@link getFunctions}
Typically, you will not use this method; it will be called using the results pulled from {@link Zend_XmlRpc_Server_Cache::get()}.
DetailssendArgumentsToAllMethods(
$flag
=
null
)
:
Send arguments to all methods?
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
DetailssetClass(
string|object $class, string $namespace, mixed $argv
=
null
)
:
voidAttach 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.
DetailssetEncoding(
string $encoding
)
:
Zend_XmlRpc_ServerSet encoding
DetailssetPersistence(
mixed $mode
)
:
voidDo nothing; persistence is handled via {@link Zend_XmlRpc_Server_Cache}
DetailssetRequest(
string|Zend_XmlRpc_Request $request
)
:
Zend_XmlRpc_ServerSet the request object
DetailssetResponseClass(
string $class
)
:
booleanSet the class to use for the response
Details