Example #1
0
 public static function fault($code, $message)
 {
     return ripcord::fault($code, $message);
 }
Example #2
0
 /**
  * Handles the given request xml
  * @param string $request_xml The incoming request.
  * @return string
  */
 public function handle($request_xml)
 {
     $result = $this->parseRequest($request_xml);
     if (!$result || ripcord::isFault($result)) {
         return $result;
     } else {
         $method = $result['methodName'];
         $params = $result['params'];
     }
     if ($method == 'system.multiCall' || $method == 'system.multicall') {
         // php's xml-rpc server (xmlrpc-epi) crashes on multicall, so handle it ourselves... fixed in php 5.3.2
         $result = $this->multiCall($params);
     } else {
         try {
             $result = xmlrpc_server_call_method($this->xmlrpc, $request_xml, null, $this->outputOptions);
         } catch (Exception $e) {
             $result = xmlrpc_encode_request(null, ripcord::fault($e->getCode(), $e->getMessage()), $this->outputOptions);
         }
     }
     return $result;
 }
Example #3
0
 /**
  * Runs the rpc server. Automatically handles an incoming request.
  */
 public function run()
 {
     if ($this->documentor) {
         $this->documentor->setMethodData($this->methods);
     }
     $request_xml = file_get_contents('php://input');
     if (!$request_xml) {
         if (($query = $_SERVER['QUERY_STRING']) && isset($this->wsdl[$query]) && $this->wsdl[$query]) {
             header('Content-type: text/xml');
             header('Access-Control-Allow-Origin: *');
             echo $this->wsdl[$query];
         } elseif ($this->documentor) {
             header('Content-type: text/html; charset=' . $this->outputOptions['encoding']);
             $this->documentor->handle($this, $this->methods);
         } else {
             // FIXME: add check for json-rpc protocol, if set and none of the xml protocols are set, use that
             header('Content-type: text/xml');
             header('Access-Control-Allow-Origin: *');
             echo xmlrpc_encode_request(null, ripcord::fault(-1, 'No request xml found.'), $this->outputOptions);
         }
     } else {
         // FIXME: add check for the protocol of the request, could be json-rpc, then check if it is supported.
         header('Content-type: text/xml');
         header('Access-Control-Allow-Origin: *');
         echo $this->handle($request_xml);
     }
 }