Example #1
0
 /**
  * Get the XML response of the XMLRPC server
  * 
  * @return string XML response
  */
 public function getResponse()
 {
     try {
         set_error_handler(array('XML_RPC2_Backend_Php_Server', 'errorToException'));
         $request = @simplexml_load_string($GLOBALS['HTTP_RAW_POST_DATA']);
         // TODO : do not use exception but a XMLRPC error !
         if (!is_object($request)) {
             throw new XML_RPC2_FaultException('Unable to parse request XML', 0);
         }
         $request = XML_RPC2_Backend_Php_Request::createFromDecode($request);
         $methodName = $request->getMethodName();
         $arguments = $request->getParameters();
         if ($this->signatureChecking) {
             $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, $arguments)) {
                 return XML_RPC2_Backend_Php_Response::encodeFault(-32602, 'server error. invalid method parameters');
             }
         }
         restore_error_handler();
         return XML_RPC2_Backend_Php_Response::encode(call_user_func_array(array($this->callHandler, $methodName), $arguments));
     } 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());
     }
 }
 /**
  * get the XML response of the XMLRPC server
  *
  * @return string the XML response
  */
 public function getResponse()
 {
     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());
     }
 }