XmlRpc/Server.php

Show: PublicProtectedPrivateinherited
Table of Contents
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.
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_XmlRpc  
Subpackage
Server  
Version
$Id$  

\Zend_XmlRpc_Server

Package: 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-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Properties

>VPropertyprotectedstring $_encoding = 'UTF-8'
Character encoding
Default value'UTF-8'Details
Type
string
>VPropertyprotectednull|\Zend_XmlRpc_Request $_request = null
Request processed
Default valuenullDetails
Type
null | \Zend_XmlRpc_Request
>VPropertyprotectedstring $_responseClass = 'Zend_XmlRpc_Response_Http'
Class to use for responses; defaults to {@link Zend_XmlRpc_Response_Http}
Default value'Zend_XmlRpc_Response_Http'Details
Type
string
>VPropertyprotectedbool $_sendArgumentsToAllMethods = true
Send arguments to all methods or just constructor?
Default valuetrueDetails
Type
bool
>VPropertyprotected\Zend_Server_Definition $_table
Dispatch table of name => method pairs
>VPropertyprotectedarray $_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
Default valuearray('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

Methods

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

Proxy calls to system object

Parameters
NameTypeDescription
$methodstring
$paramsarray
Returns
TypeDescription
mixed
Throws
ExceptionDescription
\Zend_XmlRpc_Server_Exception
methodpublic__construct() : void

Constructor

Creates system.* methods.
methodprotected_fixType(string $type) : string

Map PHP type to XML-RPC type

Parameters
NameTypeDescription
$typestring
Returns
TypeDescription
string
methodprotected_handle(\Zend_XmlRpc_Request $request) : \Zend_XmlRpc_Response

Handle an xmlrpc call (actual work)

Parameters
NameTypeDescription
$request\Zend_XmlRpc_Request
Returns
TypeDescription
\Zend_XmlRpc_Response
Throws
ExceptionDescription
\Zend_XmlRpcServer_Exception | \ExceptionZend_XmlRpcServer_Exceptions are thrown for internal errors; otherwise, any other exception may be thrown by the callback
methodprotected_registerSystemMethods() : void

Register system methods with the server

methodpublicaddFunction(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.
Parameters
NameTypeDescription
$functionstring | array

Valid callback

$namespacestring

Optional namespace prefix

Throws
ExceptionDescription
\Zend_XmlRpc_Server_Exception
methodpublicfault(string | \Exception $fault = null, int $code = 404) : \Zend_XmlRpc_Server_Fault

Raise an xmlrpc server fault

Parameters
NameTypeDescription
$faultstring | \Exception
$codeint
Returns
TypeDescription
\Zend_XmlRpc_Server_Fault
methodpublicgetDispatchTable() : array

Retrieve dispatch table

Returns
TypeDescription
array
methodpublicgetEncoding() : string

Retrieve current encoding

Returns
TypeDescription
string
methodpublicgetFunctions() : array

Returns a list of registered methods

Returns an array of dispatchables (Zend_Server_Reflection_Function, _Method, and _Class items).
Returns
TypeDescription
array
methodpublicgetRequest() : null | \Zend_XmlRpc_Request

Return currently registered request object

Returns
TypeDescription
null | \Zend_XmlRpc_Request
methodpublicgetResponseClass() : string

Retrieve current response class

Returns
TypeDescription
string
methodpublicgetSystem() : \Zend_XmlRpc_Server_System

Retrieve system object

Returns
TypeDescription
\Zend_XmlRpc_Server_System
methodpublichandle(\Zend_XmlRpc_Request $request = false) : \Zend_XmlRpc_Response | \Zend_XmlRpc_Fault

Handle an xmlrpc call

Parameters
NameTypeDescription
$request\Zend_XmlRpc_Request

Optional

Returns
TypeDescription
\Zend_XmlRpc_Response | \Zend_XmlRpc_Fault
methodpublicloadFunctions(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 {@link Zend_XmlRpc_Server_Cache::get()}.
Parameters
NameTypeDescription
$definitionarray | \Zend_Server_Definition
Throws
ExceptionDescription
\Zend_XmlRpc_Server_Exceptionon invalid input
methodpublicsendArgumentsToAllMethods( $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
Parameters
NameTypeDescription
$flag
methodpublicsetClass(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.
Parameters
NameTypeDescription
$classstring | object
$namespacestring

Optional

$argvmixed

Optional arguments to pass to methods

Throws
ExceptionDescription
\Zend_XmlRpc_Server_Exceptionon invalid input
methodpublicsetEncoding(string $encoding) : \Zend_XmlRpc_Server

Set encoding

Parameters
NameTypeDescription
$encodingstring
Returns
TypeDescription
\Zend_XmlRpc_Server
methodpublicsetPersistence(mixed $mode) : void

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

Parameters
NameTypeDescription
$modemixed
methodpublicsetRequest(string | \Zend_XmlRpc_Request $request) : \Zend_XmlRpc_Server

Set the request object

Parameters
NameTypeDescription
$requeststring | \Zend_XmlRpc_Request
Returns
TypeDescription
\Zend_XmlRpc_Server
Throws
ExceptionDescription
\Zend_XmlRpc_Server_Exceptionon invalid request class or object
methodpublicsetResponseClass(string $class) : boolean

Set the class to use for the response

Parameters
NameTypeDescription
$classstring
Returns
TypeDescription
booleanTrue if class was set, false if not
Documentation was generated by phpDocumentor 2.2.0 .