ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
XML_RPC2_Backend_Xmlrpcext_Server Class Reference
+ Inheritance diagram for XML_RPC2_Backend_Xmlrpcext_Server:
+ Collaboration diagram for XML_RPC2_Backend_Xmlrpcext_Server:

Public Member Functions

 __construct ($callHandler, $options=array())
 Create a new XML-RPC Server.
 handleCall ()
 Respond to the XML-RPC request.
 getResponse ()
 get the XML response of the XMLRPC server
- Public Member Functions inherited from XML_RPC2_Server
 autoDocument ()
 autoDocument.

Protected Member Functions

 epiFunctionHandlerAdapter ($method_name, $params, $app_data)
 This is an adapter between XML_RPC2_CallHandler::__call and xmlrpc_server_register_method callback interface.
- Protected Member Functions inherited from XML_RPC2_Server
 getContentLength ($content)
 Gets the content legth of a serialized XML-RPC message in bytes.

Private Attributes

 $_xmlrpcextServer

Additional Inherited Members

- Static Public Member Functions inherited from XML_RPC2_Server
static create ($callTarget, $options=array())
 Factory method to select a backend and return a new XML_RPC2_Server based on the backend.
static errorToException ($errno, $errstr, $errfile, $errline)
 Transform an error into an exception.
- Protected Attributes inherited from XML_RPC2_Server
 $callHandler = null
 $prefix = ''
 $encoding = 'iso-8859-1'
 $autoDocument = true
 $autoDocumentExternalLinks = true
 $signatureChecking = true

Detailed Description

Definition at line 64 of file Server.php.

Constructor & Destructor Documentation

XML_RPC2_Backend_Xmlrpcext_Server::__construct (   $callHandler,
  $options = array() 
)

Create a new XML-RPC Server.

The constructor receives a mandatory parameter: the Call Handler. The call handler executes the actual method call. XML_RPC2 server acts as a protocol decoder/encoder between the call handler and the client

Parameters
object$callHandler
array$optionsassociative array of options

Reimplemented from XML_RPC2_Server.

Definition at line 88 of file Server.php.

References XML_RPC2_Server\$callHandler.

{
$this->_xmlrpcextServer = xmlrpc_server_create();
foreach ($callHandler->getMethods() as $method) {
if (xmlrpc_server_register_method($this->_xmlrpcextServer,
$method->getName(),
array($this, 'epiFunctionHandlerAdapter')) !== true) {
throw new XML_RPC2_Exception('Unable to setup XMLRPCext server. xmlrpc_server_register_method returned non-true.');
}
}
}

Member Function Documentation

XML_RPC2_Backend_Xmlrpcext_Server::epiFunctionHandlerAdapter (   $method_name,
  $params,
  $app_data 
)
protected

This is an adapter between XML_RPC2_CallHandler::__call and xmlrpc_server_register_method callback interface.

Parameters
stringMethod name
arrayParameters
arrayApplication data (ignored)

Definition at line 111 of file Server.php.

{
return @call_user_func_array(array($this->callHandler, $method_name), $params);
}
XML_RPC2_Backend_Xmlrpcext_Server::getResponse ( )

get the XML response of the XMLRPC server

Returns
string the XML response

Definition at line 144 of file Server.php.

References $GLOBALS, XML_RPC2_Backend_Php_Response\encodeFault(), and XML_RPC2_FaultException\getFaultCode().

Referenced by handleCall().

{
try {
if ($this->signatureChecking) {
$tmp = xmlrpc_parse_method_descriptions($GLOBALS['HTTP_RAW_POST_DATA']);
$methodName = $tmp['methodName'];
$parameters = xmlrpc_decode($GLOBALS['HTTP_RAW_POST_DATA'], $this->encoding);
$method = $this->callHandler->getMethod($methodName);
if (!($method)) {
// see http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php for standard error codes
return (XML_RPC2_Backend_Php_Response::encodeFault(-32601, 'server error. requested method not found'));
}
if (!($method->matchesSignature($methodName, $parameters))) {
return (XML_RPC2_Backend_Php_Response::encodeFault(-32602, 'server error. invalid method parameters'));
}
}
set_error_handler(array('XML_RPC2_Backend_Xmlrpcext_Server', 'errorToException'));
$response = @xmlrpc_server_call_method($this->_xmlrpcextServer,
$GLOBALS['HTTP_RAW_POST_DATA'],
null,
array('output_type' => 'xml', 'encoding' => $this->encoding));
restore_error_handler();
return $response;
} catch (XML_RPC2_FaultException $e) {
return (XML_RPC2_Backend_Php_Response::encodeFault($e->getFaultCode(), $e->getMessage()));
} catch (Exception $e) {
return (XML_RPC2_Backend_Php_Response::encodeFault(1, 'Unhandled ' . get_class($e) . ' exception:' . $e->getMessage()));
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

XML_RPC2_Backend_Xmlrpcext_Server::handleCall ( )

Respond to the XML-RPC request.

handleCall reads the XML-RPC request from the raw HTTP body and decodes it. It then calls the corresponding method in the call handler class, returning the encoded result to the client.

Reimplemented from XML_RPC2_Server.

Definition at line 124 of file Server.php.

References $GLOBALS, XML_RPC2_Server\autoDocument(), XML_RPC2_Server\getContentLength(), and getResponse().

{
if ((!($this->autoDocument)) or ((isset($GLOBALS['HTTP_RAW_POST_DATA'])) && (strlen($GLOBALS['HTTP_RAW_POST_DATA'])>0))) {
$response = $this->getResponse();
header('Content-type: text/xml; charset=' . $this->encoding);
header('Content-length: ' . $this->getContentLength($response));
print $response;
} else {
$this->autoDocument();
}
}

+ Here is the call graph for this function:

Field Documentation

XML_RPC2_Backend_Xmlrpcext_Server::$_xmlrpcextServer
private

Definition at line 74 of file Server.php.


The documentation for this class was generated from the following file: