2100. Class

2100.1. Zend\XmlRpc\Server

An XML-RPC server implementation

Example: <code> use ZendXmlRpc;

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

// Allow some exceptions to report as fault responses: XmlRpcServerFault::attachFaultException(‘My\Exception’); XmlRpcServerFault::attachObserver(‘My\Fault\Observer’);

// Get or build dispatch table: if (!XmlRpcServerCache::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 XmlRpcServerCache::save($filename, $server);

}

$response = $server->handle(); echo $response; </code>

2100.1.1. Methods

2100.1.1.1. __construct

__construct()

Constructor

Creates system.* methods.

2100.1.1.2. __call

__call()

Proxy calls to system object

Parameters:
  • string
  • array
Return type:

mixed

Throws :

ServerExceptionBadMethodCallException

2100.1.1.3. addFunction

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.

Parameters:
  • string|array|callable – Valid callback
  • string – Optional namespace prefix
Throws ServerExceptionInvalidArgumentException:
 
Return type:

void

2100.1.1.4. setClass

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.

Parameters:
  • string|object
  • string – Optional
  • mixed – Optional arguments to pass to methods
Return type:

void

Throws :

ServerExceptionInvalidArgumentException on invalid input

2100.1.1.5. fault

fault()

Raise an xmlrpc server fault

Parameters:
  • string|Exception
  • int
Return type:

ServerFault

2100.1.1.6. setReturnResponse

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

Parameters:bool
Return type:Server

2100.1.1.7. getReturnResponse

getReturnResponse()

Retrieve return response flag

Return type:bool

2100.1.1.8. handle

handle()

Handle an xmlrpc call

Parameters:Request – Optional
Return type:Response|Fault

2100.1.1.9. loadFunctions

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

Parameters:array|Definition
Return type:void
Throws :ServerExceptionInvalidArgumentException on invalid input

2100.1.1.10. setEncoding

setEncoding()

Set encoding

Parameters:string
Return type:Server

2100.1.1.11. getEncoding

getEncoding()

Retrieve current encoding

Return type:string

2100.1.1.12. setPersistence

setPersistence()

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

Parameters:mixed
Return type:void

2100.1.1.13. setRequest

setRequest()

Set the request object

Parameters:string|Request
Return type:Server
Throws :ServerExceptionInvalidArgumentException on invalid request class or object

2100.1.1.14. getRequest

getRequest()

Return currently registered request object

Return type:null|Request

2100.1.1.15. getResponse

getResponse()

Last response.

Return type:Response

2100.1.1.16. setResponseClass

setResponseClass()

Set the class to use for the response

Parameters:string
Throws ServerExceptionInvalidArgumentException:
 if invalid response class
Return type:bool True if class was set, false if not

2100.1.1.17. getResponseClass

getResponseClass()

Retrieve current response class

Return type:string

2100.1.1.18. getDispatchTable

getDispatchTable()

Retrieve dispatch table

Return type:array

2100.1.1.19. getFunctions

getFunctions()

Returns a list of registered methods

Returns an array of dispatchables (ZendServerReflectionReflectionFunction, ReflectionMethod, and ReflectionClass items).

Return type:array

2100.1.1.20. getSystem

getSystem()

Retrieve system object

Return type:ServerSystem

2100.1.1.21. sendArgumentsToAllMethods

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

2100.1.1.22. _fixType

_fixType()

Map PHP type to XML-RPC type

Parameters:string
Return type:string

2100.1.1.23. handleRequest

handleRequest()

Handle an xmlrpc call (actual work)

Parameters:Request
Return type:Response
Throws :ServerExceptionRuntimeException ZendXmlRpcServerExceptions are thrown for internal errors; otherwise,

any other exception may be thrown by the callback

2100.1.1.24. registerSystemMethods

registerSystemMethods()

Register system methods with the server

Return type:void

2100.1.1.25. isSubclassOf

isSubclassOf()

Checks if the object has this class as one of its parents

Parameters:
  • string
  • string
Return type:

bool