private static function composeJsonRequest(RpcRequest $request) { $return = array("jsonrpc" => "2.0", "method" => $request->getMethod(), "params" => $request->getParameters()); $rid = $request->getId(); if ($rid === true) { $id = $return["id"] = $request->getUniqueId(); } else { if (is_scalar($rid)) { $id = $return["id"] = $rid; } else { $id = null; } } return array($return, $id); }
private function encodeSingleCall(RpcRequest $request) { $this->logger->notice("Performing a single XML call"); $this->logger->debug("Data dump before encoding", $request->toArray()); try { // encoding foreach ($request->getSpecialTypes() as $key => $value) { $this->encoder->setValueType($key, $value); } $encoded_request = $this->encoder->encodeCall($request->getMethod(), $request->getParameters()); } catch (XmlrpcException $xe) { throw $xe; } $this->logger->debug("Data dump after encoding: " . $encoded_request); return $encoded_request; }
public function testMulticall() { $string = "comodojo"; try { $this->rpch->addRequest(RpcRequest::create("add", array(40, 2)))->addRequest(RpcRequest::create("echo", array($string))); $result = $this->rpch->send(); } catch (\Exception $e) { throw $e; } $this->assertSame(42, $result[0]['result']); $this->assertSame($string, $result[1]['result']); }
private function commonRequests($method, $parameters = array()) { try { $request = RpcRequest::create($method, $parameters); $this->rpch->addRequest($request); $this->rpch->transport()->setTimeout(3); $result = $this->rpch->send(); } catch (\Exception $e) { throw $e; } return $result; }
public static function create($method, $parameters = array(), $id = true) { $request = new RpcRequest(); try { $request->setMethod($method)->setParameters($parameters)->setId($id); } catch (Exception $e) { throw $e; } return $request; }