/** * @param \Blar\Events\Event $event Event. */ public function responseReceivedCallback($event) { $response = $event->getTarget(); $decoded = Xmlrpc::decodeResponse($response->getBody()); if (Xmlrpc::isFault($decoded)) { throw new Exception($decoded['faultString'], $decoded['faultCode']); } $response->setBody($decoded); }
/** * @param string $methodName * @param array $arguments * @return mixed * @throws \Exception */ public function __call($methodName, $arguments) { if ($this->getNamespace()) { $methodName = $this->getNamespace() . '.' . $methodName; } $methodCall = Xmlrpc::encodeRequest($methodName, $arguments); $request = $this->createRequest(); $request->setUrl($this->getEndpoint()); $request->setBody($methodCall); $response = $request->send(); $data = Xmlrpc::decodeResponse($response->getBody()); if (Xmlrpc::isFault($data)) { throw new Exception($data['faultString'], $data['faultCode']); } return $data; }