/** * Perform an XML-RPC request and return a response. * * @param \Zend\XmlRpc\Request $request * @param null|\Zend\XmlRpc\Response $response * @return void * @throws \Zend\XmlRpc\Client\Exception\HttpException */ public function doRequest($request, $response = null) { $this->lastRequest = $request; if (PHP_VERSION_ID < 50600) { iconv_set_encoding('input_encoding', 'UTF-8'); iconv_set_encoding('output_encoding', 'UTF-8'); iconv_set_encoding('internal_encoding', 'UTF-8'); } else { ini_set('default_charset', 'UTF-8'); } $http = $this->getHttpClient(); $httpRequest = $http->getRequest(); if ($httpRequest->getUriString() === null) { $http->setUri($this->serverAddress); } $headers = $httpRequest->getHeaders(); $headers->addHeaders(array('Content-Type: text/xml; charset=utf-8', 'Accept: text/xml')); if (!$headers->get('user-agent')) { $headers->addHeaderLine('user-agent', 'Zend_XmlRpc_Client'); } $xml = $this->lastRequest->__toString(); $http->setRawBody($xml); $httpResponse = $http->setMethod('POST')->send(); if (!$httpResponse->isSuccess()) { /** * Exception thrown when an HTTP error occurs */ throw new Client\Exception\HttpException($httpResponse->getReasonPhrase(), $httpResponse->getStatusCode()); } if ($response === null) { $response = new Response(); } $this->lastResponse = $response; $this->lastResponse->loadXml(trim($httpResponse->getBody())); }
/** * __toString() test */ public function test__toString() { $argv = array('string', true); $this->_request->setMethod('do.Something'); $this->_request->setParams($argv); $xml = $this->_request->__toString(); $this->_testXmlRequest($xml, $argv); }