Ejemplo n.º 1
0
 /**
  * Serve request
  *
  * @return string
  * @throws Exception
  */
 public function serve()
 {
     $this->logger->notice("Start serving request");
     $parameters_object = new Parameters($this->capabilities, $this->methods, $this->errors, $this->logger, $this->protocol);
     try {
         $this->logger->debug("Received payload: " . $this->payload);
         $payload = $this->uncan($this->payload);
         $this->logger->debug("Decoded payload", (array) $payload);
         if ($this->protocol == self::XMLRPC) {
             $result = XmlProcessor::process($payload, $parameters_object, $this->logger);
         } else {
             if ($this->protocol == self::JSONRPC) {
                 $result = JsonProcessor::process($payload, $parameters_object, $this->logger);
             } else {
                 throw new Exception('Invalid or unsupported RPC protocol');
             }
         }
     } catch (RpcException $re) {
         return $this->can($re, true);
     } catch (Exception $e) {
         throw $e;
     }
     return $this->can($result, false);
 }