Zend Framework  3.0
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Server Class Reference

An XML-RPC server implementation. More...

Public Member Functions

 __construct ()
 Constructor.
 
 __call ($method, $params)
 Proxy calls to system object.
 
 addFunction ($function, $namespace= '')
 Attach a callback as an XMLRPC method.
 
 setClass ($class, $namespace= '', $argv=null)
 Attach class methods as XMLRPC method handlers.
 
 fault ($fault=null, $code=404)
 Raise an xmlrpc server fault.
 
 setReturnResponse ($flag=true)
 Set return response flag.
 
 getReturnResponse ()
 Retrieve return response flag.
 
 handle ($request=false)
 Handle an xmlrpc call.
 
 loadFunctions ($definition)
 Load methods as returned from getFunctions.
 
 setEncoding ($encoding)
 Set encoding.
 
 getEncoding ()
 Retrieve current encoding.
 
 setPersistence ($mode)
 Do nothing; persistence is handled via Zend.
 
 setRequest ($request)
 Set the request object.
 
 getRequest ()
 Return currently registered request object.
 
 getResponse ()
 Last response.
 
 setResponseClass ($class)
 Set the class to use for the response.
 
 getResponseClass ()
 Retrieve current response class.
 
 getDispatchTable ()
 Retrieve dispatch table.
 
 getFunctions ()
 Returns a list of registered methods.
 
 getSystem ()
 Retrieve system object.
 
 sendArgumentsToAllMethods ($flag=null)
 Send arguments to all methods?
 
- Public Member Functions inherited from AbstractServer
 __construct ()
 Constructor.
 
 getFunctions ()
 Returns a list of registered methods.
 

Protected Member Functions

 _fixType ($type)
 Map PHP type to XML-RPC type.
 
 handleRequest (Request $request)
 Handle an xmlrpc call (actual work)
 
 registerSystemMethods ()
 Register system methods with the server.
 
- Protected Member Functions inherited from AbstractServer
 _buildCallback (Reflection\AbstractFunction $reflection)
 Build callback for method signature.
 
 _buildSignature (Reflection\AbstractFunction $reflection, $class=null)
 Build a method signature.
 
 _dispatch (Method\Definition $invokable, array $params)
 Dispatch method.
 
 _fixType ($type)
 Map PHP type to protocol type.
 

Static Protected Member Functions

static isSubclassOf ($className, $type)
 Checks if the object has this class as one of its parents.
 

Protected Attributes

 $encoding = 'UTF-8'
 
 $request = null
 
 $responseClass = 'Zend\XmlRpc\Response\Http'
 
 $table
 
 $typeMap
 
 $sendArgumentsToAllMethods = true
 
 $returnResponse = false
 
 $response
 
- Protected Attributes inherited from AbstractServer
 $overwriteExistingMethods = false
 
 $table
 

Detailed Description

An XML-RPC server implementation.

Example: use Zend;

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

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

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

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

Constructor & Destructor Documentation

__construct ( )

Constructor.

Creates system.* methods.

Member Function Documentation

__call (   $method,
  $params 
)

Proxy calls to system object.

Parameters
string$method
array$params
Returns
mixed
Exceptions
Server\Exception\BadMethodCallException
_fixType (   $type)
protected

Map PHP type to XML-RPC type.

Parameters
string$type
Returns
string
addFunction (   $function,
  $namespace = '' 
)

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$functionValid callback
string$namespaceOptional namespace prefix
Exceptions
Server\Exception\InvalidArgumentException
Returns
void

Implements Server.

fault (   $fault = null,
  $code = 404 
)

Raise an xmlrpc server fault.

Parameters
string | \Exception$fault
int$code
Returns
Server

Implements Server.

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, ReflectionMethod, and ReflectionClass items).

Returns
array

Implements Server.

getRequest ( )

Return currently registered request object.

Returns
null|Request
getResponse ( )

Last response.

Returns
Response

Implements Server.

getResponseClass ( )

Retrieve current response class.

Returns
string
getReturnResponse ( )

Retrieve return response flag.

Returns
bool

Implements Server.

getSystem ( )

Retrieve system object.

Returns
Server
handle (   $request = false)

Handle an xmlrpc call.

Parameters
Request$requestOptional
Returns
Response|Fault

Implements Server.

handleRequest ( Request  $request)
protected

Handle an xmlrpc call (actual work)

Parameters
Request$request
Returns
Response
Exceptions
Server\Exception\RuntimeExceptionZend are thrown for internal errors; otherwise, any other exception may be thrown by the callback
static isSubclassOf (   $className,
  $type 
)
staticprotected

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

See Also
https://bugs.php.net/bug.php?id=53727
https://github.com/zendframework/zf2/pull/1807
Deprecated:
since zf 2.3 requires PHP >= 5.3.23
Parameters
string$className
string$type
Returns
bool
loadFunctions (   $definition)

Load methods as returned from getFunctions.

Typically, you will not use this method; it will be called using the results pulled from ::get().

Parameters
array | Definition$definition
Returns
void
Exceptions
Server\Exception\InvalidArgumentExceptionon invalid input

Implements Server.

registerSystemMethods ( )
protected

Register system methods with the server.

Returns
void
sendArgumentsToAllMethods (   $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

Parameters
bool | null$flag
Returns
self
setClass (   $class,
  $namespace = '',
  $argv = null 
)

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$class
string$namespaceOptional
mixed$argvOptional arguments to pass to methods
Returns
void
Exceptions
Server\Exception\InvalidArgumentExceptionon invalid input

Implements Server.

setEncoding (   $encoding)

Set encoding.

Parameters
string$encoding
Returns
Server
setPersistence (   $mode)

Do nothing; persistence is handled via Zend.

Parameters
mixed$mode
Returns
void

Implements Server.

setRequest (   $request)

Set the request object.

Parameters
string | Request$request
Returns
Server
Exceptions
Server\Exception\InvalidArgumentExceptionon invalid request class or object
setResponseClass (   $class)

Set the class to use for the response.

Parameters
string$class
Exceptions
Server\Exception\InvalidArgumentExceptionif invalid response class
Returns
bool True if class was set, false if not
setReturnResponse (   $flag = true)

Set return response flag.

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

The response is always available via getResponse().

Parameters
bool$flag
Returns
Server

Implements Server.

Member Data Documentation

$encoding = 'UTF-8'
protected
$request = null
protected
$response
protected
$responseClass = 'Zend\XmlRpc\Response\Http'
protected
$returnResponse = false
protected
$sendArgumentsToAllMethods = true
protected
$table
protected
$typeMap
protected
Initial value:
= [
'i4' => 'i4'