/** * {@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()); } }
/** * @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.'); } }
/** * 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); }
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)); }
/** * @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')); }
/** * 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; }
/** * 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); }
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'); }
/** * Clear processLlogs * * @return boolean result Always True unless error */ public function clearProcessLogs() { return $this->rpcClient->call('supervisor.clearProcessLogs', array($this->processGroup . ':' . $this->processName)); }
/** * Clear all process log files * * @return boolean result Always return true */ public function clearAllProcessLogs() { return $this->rpcClient->call('supervisor.clearAllProcessLogs'); }
/** * 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); }