Class Server

Summary

Fully Qualified Name: Zend\XmlRpc\Server
Extends: AbstractServer

Description

An XML-RPC server implementation

Example: use Zend\XmlRpc;

// Instantiate server $server = new XmlRpc\Server();

// Allow some exceptions to report as fault responses: XmlRpc\Server\Fault::attachFaultException('My\Exception'); XmlRpc\Server\Fault::attachObserver('My\Fault\Observer');

// Get or build dispatch table: if (!XmlRpc\Server\Cache::get($filename, $server)) {

// 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
XmlRpc\Server\Cache::save($filename, $server);

}

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

Methods

Name Description Defined By
__call() Proxy calls to system object Server
__construct() Constructor Server
addFunction() Attach a callback as an XMLRPC method Server
fault() Raise an xmlrpc server fault Server
getDispatchTable() Retrieve dispatch table Server
getEncoding() Retrieve current encoding Server
getFunctions() Returns a list of registered methods Server
getRequest() Return currently registered request object Server
getResponse() Last response. Server
getResponseClass() Retrieve current response class Server
getReturnResponse() Retrieve return response flag Server
getSystem() Retrieve system object Server
handle() Handle an xmlrpc call Server
loadFunctions() Load methods as returned from {@link getFunctions} Server
sendArgumentsToAllMethods() Send arguments to all methods? Server
setClass() Attach class methods as XMLRPC method handlers Server
setEncoding() Set encoding Server
setPersistence() Do nothing; persistence is handled via {@link Zend\XmlRpc\Server\Cache} Server
setRequest() Set the request object Server
setResponseClass() Set the class to use for the response Server
setReturnResponse() Set return response flag Server

Method Details

__call()

Proxy calls to system object

Parameter Name Type Description
$method string
$params array

Returns: mixed

__construct()

Constructor

Creates system.* methods.

Returns:

addFunction()

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.

Parameter Name Type Description
$function string|array|callable Valid
$namespace string Optional

Returns: void

fault()

Raise an xmlrpc server fault

Parameter Name Type Description
$fault string|\Exception
$code int

Returns: \Server\Fault

getDispatchTable()

Retrieve dispatch table

Returns: array

getEncoding()

Retrieve current encoding

Returns: string

getFunctions()

Returns a list of registered methods

Returns an array of dispatchables (Zend\Server\Reflection\ReflectionFunction, ReflectionMethod, and ReflectionClass items).

Returns: array

getRequest()

Return currently registered request object

Returns: null|\Request

getResponse()

Last response.

Returns: \Response

getResponseClass()

Retrieve current response class

Returns: string

getReturnResponse()

Retrieve return response flag

Returns: bool

getSystem()

Retrieve system object

Returns: \Server\System

handle()

Handle an xmlrpc call

Parameter Name Type Description
$request \Request Optional

Returns: \Response|\Fault

loadFunctions()

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()}.

Parameter Name Type Description
$definition array|\Definition

Returns: void

sendArgumentsToAllMethods()

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

Parameter Name Type Description
$flag bool|null

Returns: self

setClass()

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.

Parameter Name Type Description
$class string|object
$namespace string Optional
$argv mixed Optional

Returns: void

setEncoding()

Set encoding

Parameter Name Type Description
$encoding string

Returns: \Server

setPersistence()

Do nothing; persistence is handled via {@link Zend\XmlRpc\Server\Cache}

Parameter Name Type Description
$mode mixed

Returns: void

setRequest()

Set the request object

Parameter Name Type Description
$request string|\Request

Returns: \Server

setResponseClass()

Set the class to use for the response

Parameter Name Type Description
$class string

Returns: bool True if class was set, false if not

setReturnResponse()

Set return response flag

If true, {@link handle()} will return the response instead of automatically sending it back to the requesting client.

The response is always available via {@link getResponse()}.

Parameter Name Type Description
$flag bool

Returns: \Server

Top