/** * @param MethodCall $methodCall * @return MethodResponse */ protected function _handle(MethodCall $methodCall) { $response = $this->call($methodCall->getMethodName(), $methodCall->getParameters()); if (!$response instanceof MethodResponse) { $response = new MethodReturn($response); } return $response; }
/** * @param MethodCall $call * @return Request */ public function createHttpRequest(MethodCall $call) { $document = new \DOMDocument("1.0", "UTF-8"); $document->appendChild($callEl = $document->createElement("methodCall")); $callEl->appendChild($methodName = $document->createElement("methodName", $call->getMethodName())); $callEl->appendChild($paramsEl = $document->createElement("params")); foreach ($call->getParameters() as $parameter) { $paramsEl->appendChild($paramEl = $document->createElement("param")); $paramEl->appendChild($this->pack($document, $parameter)); } $httpRequest = new Request(array(), array(), array(), array(), array(), array(), $document->saveXML()); $httpRequest->headers->add(array("content-type" => "text/xml")); return $httpRequest; }
/** * @param MethodCall $call * @return Request */ public function createHttpRequest(MethodCall $call) { $data = array('jsonrpc' => '2.0', 'method' => $call->getMethodName(), 'params' => $call->getParameters()); if ($call->getCallId()) { $data['id'] = $call->getCallId(); } $httpRequest = new Request(array(), array(), array(), array(), array(), array(), json_encode($data)); $httpRequest->headers->add(array("content-type" => "text/json")); return $httpRequest; }