예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function call($namespace, $method, array $arguments = [])
 {
     try {
         return $this->client->call($namespace . '.' . $method, $arguments);
     } catch (FaultException $e) {
         throw Fault::create($e->getMessage(), $e->getCode());
     }
 }
예제 #2
0
 /**
  * @param string $method
  * @param array  $params
  *
  * @return mixed
  * @throws AuthenticationException
  * @throws ConnectionException
  * @throws SupervisorException
  */
 public function callMethod($method, array $params = [])
 {
     try {
         return $this->_connection->call($method, $params);
     } catch (RuntimeException $error) {
         throw new ConnectionException('Unable to connect to supervisor XML RPC server.');
     } catch (HttpException $error) {
         throw new AuthenticationException('Authentication failed. Check user name and password.');
     } catch (FaultException $error) {
         $methodName = isset($error->getTrace()[0]['args'][0]) ? $error->getTrace()[0]['args'][0] : 'Unknown';
         throw new SupervisorException('Method: ' . $methodName . ' was not found in supervisor RPC API.');
     }
 }
예제 #3
0
파일: Client.php 프로젝트: slkxmail/App
 /**
  * Send an XML-RPC request to the service (for a specific method)
  *
  * @param  string $method Name of the method we want to call
  * @param  array $params Array of parameters for the method
  * @param  string $requestType Type of the request \App\XmlRpc\Client::XMLRPC_REQUEST_*
  * @return mixed
  * @throws Zend_XmlRpc_Client_FaultException
  */
 public function call($method, $params = array(), $requestType = \App\XmlRpc\Client::XMLRPC_REQUEST_FAST)
 {
     $timeout = self::$_fastRequestTimeout;
     if ($requestType == self::XMLRPC_REQUEST_SLOW) {
         $timeout = self::$_slowRequestTimeout;
     }
     $this->getHttpClient()->setOptions(array('timeout' => $timeout));
     return parent::call($method, $params);
 }
예제 #4
0
 public function call($url, $method, $arguments, $userId = null)
 {
     if ($userId) {
         $this->userId = $userId;
     }
     if (!self::$token) {
         $this->authenticate();
     }
     $client = new XmlRpcClient(REALTIME_URL . $url);
     return $client->call($method, array_merge([self::$token], $arguments));
 }
예제 #5
0
 /**
  * @group ZF-1897
  */
 public function testHandlesLeadingOrTrailingWhitespaceInChunkedResponseProperly()
 {
     $baseUri = "http://foo:80";
     $this->httpAdapter = new Adapter\Test();
     $this->httpClient = new Http\Client(null, array('adapter' => $this->httpAdapter));
     $respBody = file_get_contents(dirname(__FILE__) . "/_files/ZF1897-response-chunked.txt");
     $this->httpAdapter->setResponse($respBody);
     $this->xmlrpcClient = new Client($baseUri);
     $this->xmlrpcClient->setHttpClient($this->httpClient);
     $this->assertEquals('FOO', $this->xmlrpcClient->call('foo'));
 }
예제 #6
0
 /**
  * Does a query to the RPC host
  *
  * @param string $method
  * @param array $search
  * @return bool|array
  */
 public function doQuery($method, $search)
 {
     try {
         $username = '******';
         $password = '******';
         $RpcClient = new RpcClient('http://172.17.100.201:1337/XMLRPC');
         $httpClient = $RpcClient->getHttpClient();
         $httpClient->setAuth($username, $password);
         $return = $RpcClient->call($method, $search);
     } catch (\Exception $e) {
         $return = false;
     }
     return $return;
 }
예제 #7
0
 /**
  * Call a method in this namespace.
  *
  * @param  string $method
  * @param  array $args
  * @return mixed
  */
 public function __call($method, $args)
 {
     $method = ltrim("{$this->namespace}.{$method}", '.');
     return $this->client->call($method, $args);
 }
예제 #8
0
 function it_throws_a_known_exception_when_proper_fault_returned(Client $client)
 {
     $e = new FaultException('UNKNOWN_METHOD', 1);
     $client->call('namespace.method', [])->willThrow($e);
     $this->shouldThrow('Indigo\\Supervisor\\Exception\\Fault\\UnknownMethod')->duringCall('namespace', 'method');
 }
예제 #9
0
 /**
  * Clear processLlogs
  *
  * @return boolean result Always True unless error
  */
 public function clearProcessLogs()
 {
     return $this->rpcClient->call('supervisor.clearProcessLogs', array($this->processGroup . ':' . $this->processName));
 }
예제 #10
0
 /**
  * Clear all process log files
  *
  * @return boolean result Always return true
  */
 public function clearAllProcessLogs()
 {
     return $this->rpcClient->call('supervisor.clearAllProcessLogs');
 }
예제 #11
0
 /**
  * Call a method in this namespace.
  *
  * @param  string $methodN
  * @param  array $args
  * @return mixed
  */
 public function __call($method, $args)
 {
     $method = ltrim("$this->_namespace.$method", '.');
     return $this->_client->call($method, $args);
 }