ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
XML_RPC2_Backend_Php_Server Class Reference
+ Inheritance diagram for XML_RPC2_Backend_Php_Server:
+ Collaboration diagram for XML_RPC2_Backend_Php_Server:

Public Member Functions

 __construct ($callHandler, $options=array())
 Create a new XML-RPC Server. More...
 
 handleCall ()
 Receive the XML-RPC request, decode the HTTP payload, delegate execution to the call handler, and output the encoded call handler response. More...
 
 getResponse ()
 Get the XML response of the XMLRPC server. More...
 
- Public Member Functions inherited from XML_RPC2_Server
 handleCall ()
 Receive the XML-RPC request, decode the HTTP payload, delegate execution to the call handler, and output the encoded call handler response. More...
 
 autoDocument ()
 autoDocument. More...
 

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. More...
 
static errorToException ($errno, $errstr, $errfile, $errline)
 Transform an error into an exception. More...
 
- Protected Member Functions inherited from XML_RPC2_Server
 __construct ($callHandler, $options=array())
 Create a new XML-RPC Server. More...
 
 getContentLength ($content)
 Gets the content legth of a serialized XML-RPC message in bytes. More...
 
- 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

◆ __construct()

XML_RPC2_Backend_Php_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 public

Definition at line 79 of file Server.php.

References XML_RPC2_Server\$callHandler, and $options.

80  {
81  parent::__construct($callHandler, $options);
82  }
if(!is_array($argv)) $options

Member Function Documentation

◆ getResponse()

XML_RPC2_Backend_Php_Server::getResponse ( )

Get the XML response of the XMLRPC server.

Returns
string XML response

Definition at line 111 of file Server.php.

References XML_RPC2_Server\$encoding, $GLOBALS, XML_RPC2_Backend_Php_Request\createFromDecode(), XML_RPC2_Backend_Php_Response\encode(), XML_RPC2_Backend_Php_Response\encodeFault(), and XML_RPC2_FaultException\getFaultCode().

Referenced by handleCall().

112  {
113  try {
114  set_error_handler(array('XML_RPC2_Backend_Php_Server', 'errorToException'));
115  $request = @simplexml_load_string($GLOBALS['HTTP_RAW_POST_DATA']);
116  // TODO : do not use exception but a XMLRPC error !
117  if (!is_object($request)) throw new XML_RPC2_FaultException('Unable to parse request XML', 0);
119  $methodName = $request->getMethodName();
120  $arguments = $request->getParameters();
121  if ($this->signatureChecking) {
122  $method = $this->callHandler->getMethod($methodName);
123  if (!($method)) {
124  // see http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php for standard error codes
125  return (XML_RPC2_Backend_Php_Response::encodeFault(-32601, 'server error. requested method not found'));
126  }
127  if (!($method->matchesSignature($methodName, $arguments))) {
128  return (XML_RPC2_Backend_Php_Response::encodeFault(-32602, 'server error. invalid method parameters'));
129  }
130  }
131  restore_error_handler();
132  return (XML_RPC2_Backend_Php_Response::encode(call_user_func_array(array($this->callHandler, $methodName), $arguments), $this->encoding));
133  } catch (XML_RPC2_FaultException $e) {
135  } catch (Exception $e) {
136  return (XML_RPC2_Backend_Php_Response::encodeFault(1, 'Unhandled ' . get_class($e) . ' exception:' . $e->getMessage() . $e->getTraceAsString(), $this->encoding));
137  }
138  }
static createFromDecode($simpleXML)
Decode a request from XML and construct a request object with the createFromDecoded values...
Definition: Request.php:187
static encodeFault($code, $message, $encoding='iso-8859-1')
Encode a fault XML-RPC response, containing the provided code and message.
Definition: Response.php:102
$GLOBALS['ct_recipient']
getFaultCode()
FaultCode getter.
Definition: Exception.php:229
static encode($param, $encoding='iso-8859-1')
Encode a normal XML-RPC response, containing the provided value.
Definition: Response.php:80
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleCall()

XML_RPC2_Backend_Php_Server::handleCall ( )

Receive the XML-RPC request, decode the HTTP payload, delegate execution to the call handler, and output the encoded call handler response.

Definition at line 91 of file Server.php.

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

92  {
93  if ((!($this->autoDocument)) or ((isset($GLOBALS['HTTP_RAW_POST_DATA'])) && (strlen($GLOBALS['HTTP_RAW_POST_DATA'])>0))) {
94  $response = $this->getResponse();
95  header('Content-type: text/xml; charset=' . $this->encoding);
96  header('Content-length: ' . $this->getContentLength($response));
97  print $response;
98  } else {
99  $this->autoDocument();
100  }
101  }
autoDocument()
autoDocument.
Definition: Server.php:260
$GLOBALS['ct_recipient']
getContentLength($content)
Gets the content legth of a serialized XML-RPC message in bytes.
Definition: Server.php:318
getResponse()
Get the XML response of the XMLRPC server.
Definition: Server.php:111
+ Here is the call graph for this function:

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