Exemplo n.º 1
0
 /**
  * Index page
  */
 public function indexAction()
 {
     // get user info by api key
     if (null != ($apiKey = $this->getRequest()->getQuery()->api_key)) {
         if (null != ($userInfo = UserIdentityService::getUserInfo($apiKey, UserModelBase::USER_INFO_BY_API_KEY))) {
             // fill the user's info
             if ($userInfo['status'] == UserModelBase::STATUS_APPROVED) {
                 $userIdentity = [];
                 foreach ($userInfo as $fieldName => $value) {
                     $userIdentity[$fieldName] = $value;
                 }
                 // init user identity
                 UserIdentityService::setCurrentUserIdentity($userIdentity);
             }
         }
     }
     XmlRpcServerFault::attachFaultException('XmlRpc\\Exception\\XmlRpcActionDenied');
     $server = new XmlRpcServer();
     // get xmlrpc classes
     if (null != ($classes = $this->getModel()->getClasses())) {
         $server->sendArgumentsToAllMethods(false);
         foreach ($classes as $class) {
             $server->setClass($class['path'], $class['namespace'], $this->getServiceLocator());
         }
     }
     $server->handle();
     // disable layout and view script
     return $this->response;
 }
 public function indexAction()
 {
     $server = new Server();
     $serverObject = new Handler($this->getServiceLocator());
     $server->setClass($serverObject);
     echo $server->handle();
     exit;
 }
Exemplo n.º 3
0
 public function __construct($config, ServiceManager $serviceManager)
 {
     $this->config = $config;
     $this->serviceManager = $serviceManager;
     $this->request = $serviceManager->get('Request');
     $this->response = $serviceManager->get('Response');
     $this->server = new \Zend\XmlRpc\Server();
     $this->server->setReturnResponse(true);
     if (array_key_exists('service', $config) && is_array($config['service']) && !empty($config['service'])) {
         foreach ($config['service'] as $k => $v) {
             try {
                 $this->server->setClass($k, $v);
                 //$this->server->setClass('App\XmlRpc\Service\Cargoitem', 'cargoitem');
             } catch (\Exception $e) {
                 print_r($e->getMessage());
                 die;
             }
         }
     }
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function serve()
 {
     if (!function_exists('xmlrpc_server_create')) {
         throw new \Exception('xmlrpc extension is not installed. Please enable this extension.');
         exit;
     }
     if (!class_exists('Zend\\XmlRpc\\Server')) {
         throw new \Exception("Zend\\XmlRpc\\Server is required. " . "please install it using 'composer require zendframework/zend-xmlrpc'");
         exit;
     }
     if (isset($_GET['xmlrpc']) || isset($_GET['XMLRPC'])) {
         $server = new Server();
         $server->sendArgumentsToAllMethods(false);
         $server->setClass(get_class($this->serviceHandler), 'DBInstance', $this->authentication, $this->connectionStrings, $this->logDir);
         echo $server->handle();
     }
 }
Exemplo n.º 5
0
 /**
  * @group ZF-6034
  */
 public function testPrototypeReturnValueMustReflectDocBlock()
 {
     $server = new Server();
     $server->setClass('ZendTest\\XmlRpc\\TestClass');
     $table = $server->getDispatchTable();
     $method = $table->getMethod('test1');
     foreach ($method->getPrototypes() as $prototype) {
         $this->assertNotEquals('void', $prototype->getReturnType(), var_export($prototype, 1));
     }
 }
<?php

use Zend\XmlRpc\Server;
require_once __DIR__ . '/../../vendor/autoload.php';
class Foo
{
    public function bar()
    {
        return 'bar remote!';
    }
}
$server = new Server();
$server->setClass(new Foo(), 'Foo');
$server->setReturnResponse(false);
$server->handle();
Exemplo n.º 7
0
 /**
  * Setup environment
  */
 public function setUp()
 {
     $this->_file = realpath(__DIR__) . '/xmlrpc.cache';
     $this->_server = new Server();
     $this->_server->setClass('Zend\\XmlRpc\\Server\\Cache', 'cache');
 }