XmlRpc/Server.php
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 [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_XmlRpc
- Subpackage
- Server
- Version
- $Id: Server.php 24593 2012-01-05 20:35:02Z matthew $
\Zend_XmlRpc_Server
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;
- Parent(s)
- \Zend_Server_Abstract
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Version
- $Id: Abstract.php 24593 2012-01-05 20:35:02Z matthew $
Properties


bool $_overwriteExistingMethods = false
false
Details- Type
- bool
- Inherited_from
- \Zend_Server_Abstract::$$_overwriteExistingMethods


null|\Zend_XmlRpc_Request $_request = null
Request processed
null
Details- Type
- null | \Zend_XmlRpc_Request


string $_responseClass = 'Zend_XmlRpc_Response_Http'
Class to use for responses; defaults to {@link Zend_XmlRpc_Response_Http}
'Zend_XmlRpc_Response_Http'
Details- Type
- string


bool $_sendArgumentsToAllMethods = true
Send arguments to all methods or just constructor?
true
Details- Type
- bool


array $_typeMap = 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')
PHP types => XML-RPC types
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')
Details- Type
- array


array $magic_methods = array('__call', '__clone', '__construct', '__destruct', '__get', '__isset', '__set', '__set_state', '__sleep', '__tostring', '__unset', '__wakeup')
array('__call', '__clone', '__construct', '__destruct', '__get', '__isset', '__set', '__set_state', '__sleep', '__tostring', '__unset', '__wakeup')
Details- Type
- array
- Inherited_from
- \Zend_Server_Abstract::$$magic_methods
Methods


__call(string $method, array $params) : mixed
Proxy calls to system object
Name | Type | Description |
---|---|---|
$method | string | |
$params | array |
Type | Description |
---|---|
mixed |
Exception | Description |
---|---|
\Zend_XmlRpc_Server_Exception |


_buildCallback(\Zend_Server_Reflection_Function_Abstract $reflection) : \Zend_Server_Method_Callback
Build callback for method signature
Inherited from: \Zend_Server_Abstract::_buildCallback()Name | Type | Description |
---|---|---|
$reflection | \Zend_Server_Reflection_Function_Abstract |
Type | Description |
---|---|
\Zend_Server_Method_Callback |


_buildSignature(\Zend_Server_Reflection_Function_Abstract $reflection, null | string | object $class = null) : \Zend_Server_Method_Definition
Name | Type | Description |
---|---|---|
$reflection | \Zend_Server_Reflection_Function_Abstract | |
$class | null | string | object |
Type | Description |
---|---|
\Zend_Server_Method_Definition |
Exception | Description |
---|---|
\Zend_Server_Exception | on duplicate entry |


_dispatch(\Zend_Server_Method_Definition $invocable, array $params) : mixed
Name | Type | Description |
---|---|---|
$invocable | \Zend_Server_Method_Definition | |
$params | array |
Type | Description |
---|---|
mixed |


_fixType(string $type) : string
Map PHP type to XML-RPC type
Name | Type | Description |
---|---|---|
$type | string |
Type | Description |
---|---|
string |


_handle(\Zend_XmlRpc_Request $request) : \Zend_XmlRpc_Response
Handle an xmlrpc call (actual work)
Name | Type | Description |
---|---|---|
$request | \Zend_XmlRpc_Request |
Type | Description |
---|---|
\Zend_XmlRpc_Response |
Exception | Description |
---|---|
\Zend_XmlRpcServer_Exception | \Exception | Zend_XmlRpcServer_Exceptions are thrown for internal errors; otherwise, any other exception may be thrown by the callback |


addFunction(string | array $function, string $namespace = '') : void
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.
Name | Type | Description |
---|---|---|
$function | string | array | Valid callback |
$namespace | string | Optional namespace prefix |
Exception | Description |
---|---|
\Zend_XmlRpc_Server_Exception |


fault(string | \Exception $fault = null, int $code = 404) : \Zend_XmlRpc_Server_Fault
Raise an xmlrpc server fault
Name | Type | Description |
---|---|---|
$fault | string | \Exception | |
$code | int |
Type | Description |
---|---|
\Zend_XmlRpc_Server_Fault |


getFunctions() : array
Returns a list of registered methods
Returns an array of dispatchables (Zend_Server_Reflection_Function, _Method, and _Class items).
Type | Description |
---|---|
array |


getRequest() : null | \Zend_XmlRpc_Request
Return currently registered request object
Type | Description |
---|---|
null | \Zend_XmlRpc_Request |


getSystem() : \Zend_XmlRpc_Server_System
Retrieve system object
Type | Description |
---|---|
\Zend_XmlRpc_Server_System |


handle(\Zend_XmlRpc_Request $request = false) : \Zend_XmlRpc_Response | \Zend_XmlRpc_Fault
Handle an xmlrpc call
Requests may be passed in, or the server may automagically determine the request based on defaults. Dispatches server request to appropriate method and returns a response
Name | Type | Description |
---|---|---|
$request | \Zend_XmlRpc_Request | Optional |
Type | Description |
---|---|
\Zend_XmlRpc_Response | \Zend_XmlRpc_Fault |


loadFunctions(array | \Zend_Server_Definition $definition) : void
Load methods as returned from {@link getFunctions}
Typically, you will not use this method; it will be called using the results pulled from Zend_XmlRpc_Server_Cache::get().
Name | Type | Description |
---|---|---|
$definition | array | \Zend_Server_Definition |
Exception | Description |
---|---|
\Zend_XmlRpc_Server_Exception | on invalid input |


lowerCase( $value, string $key) : string
Lowercase's a string by reference
Name | Type | Description |
---|---|---|
$value | ||
$key | string |
Type | Description |
---|---|
string | Lower cased string |


sendArgumentsToAllMethods( $flag = null) : void
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
Name | Type | Description |
---|---|---|
$flag |


setClass(string | object $class, string $namespace = '', mixed $argv = null) : void
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.
Name | Type | Description |
---|---|---|
$class | string | object | |
$namespace | string | Optional |
$argv | mixed | Optional arguments to pass to methods |
Exception | Description |
---|---|
\Zend_XmlRpc_Server_Exception | on invalid input |


setEncoding(string $encoding) : \Zend_XmlRpc_Server
Set encoding
Name | Type | Description |
---|---|---|
$encoding | string |
Type | Description |
---|---|
\Zend_XmlRpc_Server |


setPersistence(mixed $mode) : void
Do nothing; persistence is handled via {@link Zend_XmlRpc_Server_Cache}
Name | Type | Description |
---|---|---|
$mode | mixed |


setRequest(string | \Zend_XmlRpc_Request $request) : \Zend_XmlRpc_Server
Set the request object
Name | Type | Description |
---|---|---|
$request | string | \Zend_XmlRpc_Request |
Type | Description |
---|---|
\Zend_XmlRpc_Server |
Exception | Description |
---|---|
\Zend_XmlRpc_Server_Exception | on invalid request class or object |