示例#1
0
 /**
  * Handle an xmlrpc call (actual work)
  *
  * @param Polycast_XmlRpc_Request $request
  * @return Polycast_XmlRpc_Response
  * @throws Zend_XmlRpcServer_Exception|Exception
  * Zend_XmlRpcServer_Exceptions are thrown for internal errors; otherwise,
  * any other exception may be thrown by the callback
  */
 protected function _handle(Polycast_XmlRpc_Request $request)
 {
     $method = $request->getMethod();
     // Check for valid method
     if (!$this->_table->hasMethod($method)) {
         require_once 'Polycast/XmlRpc/Server/Exception.php';
         throw new Polycast_XmlRpc_Server_Exception('Method "' . $method . '" does not exist', 620);
     }
     $info = $this->_table->getMethod($method);
     $params = $request->getParams();
     $argv = $info->getInvokeArguments();
     if (0 < count($argv) and $this->sendArgumentsToAllMethods()) {
         $params = array_merge($params, $argv);
     }
     // Check calling parameters against signatures
     $matched = false;
     $sigCalled = $request->getTypes();
     $sigLength = count($sigCalled);
     $paramsLen = count($params);
     if ($sigLength < $paramsLen) {
         for ($i = $sigLength; $i < $paramsLen; ++$i) {
             $xmlRpcValue = Polycast_XmlRpc_Value::getXmlRpcValue($params[$i]);
             $sigCalled[] = $xmlRpcValue->getType();
         }
     }
     $signatures = $info->getPrototypes();
     foreach ($signatures as $signature) {
         $sigParams = $signature->getParameters();
         if ($sigCalled === $sigParams) {
             $matched = true;
             break;
         }
     }
     if (!$matched) {
         require_once 'Polycast/XmlRpc/Server/Exception.php';
         throw new Polycast_XmlRpc_Server_Exception('Calling parameters do not match signature', 623);
     }
     $return = $this->_dispatch($info, $params);
     $responseClass = $this->getResponseClass();
     return new $responseClass($return);
 }