/**
  * Retrieve a XML-RPC message.
  *
  * @param   scriptlet.HttpScriptletResponse response
  * @return  webservices.xmlrpc.XmlRpcMessage
  */
 public function retrieve($response)
 {
     $this->cat && $this->cat->debug('<<<', $response->toString());
     $code = $response->getStatusCode();
     switch ($code) {
         case HttpConstants::STATUS_OK:
         case HttpConstants::STATUS_INTERNAL_SERVER_ERROR:
             $xml = '';
             while ($buf = $response->readData()) {
                 $xml .= $buf;
             }
             $this->cat && $this->cat->debug('<<<', $xml);
             if ($answer = XmlRpcResponseMessage::fromString($xml)) {
                 // Check encoding
                 if (NULL !== ($content_type = $response->getHeader('Content-Type'))) {
                     @(list($type, $charset) = explode('; charset=', $content_type));
                     if (!empty($charset)) {
                         $answer->setEncoding($charset);
                     }
                 }
             }
             // Fault?
             if (NULL !== ($fault = $answer->getFault())) {
                 throw new XmlRpcFaultException($fault);
             }
             return $answer;
         case HttpConstants::STATUS_AUTHORIZATION_REQUIRED:
             throw new IllegalAccessException('Authorization required: ' . $response->getHeader('WWW-Authenticate'));
         default:
             throw new IllegalStateException('Unexpected return code: ' . $response->getStatusCode());
     }
 }
 public function multipleParameters()
 {
     $this->router->setMockData('<?xml version="1.0" encoding="iso-8859-1"?>
     <methodCall>
       <methodName>DummyRpcImplementation.checkMultipleParameters</methodName>
       <params>
         <param>
           <value>
             <string>Lalala</string>
           </value>
         </param>
         <param>
           <value>
             <int>1</int>
           </value>
         </param>
         <param>
           <value>
             <array>
               <data>
                 <value><i4>12</i4></value>
                 <value><string>Egypt</string></value>
                 <value><boolean>0</boolean></value>
                 <value><i4>-31</i4></value>
               </data>
             </array>
           </value>
         </param>
         <param>
           <value>
             <struct>
               <member>
                 <name>lowerBound</name>
                 <value><i4>18</i4></value>
               </member>
               <member>
                 <name>upperBound</name>
                 <value><i4>139</i4></value>
               </member>
             </struct>
           </value>
         </param>
       </params>
     </methodCall>
   ');
     $this->router->init();
     $response = $this->router->process();
     $this->assertHasHeader($response->headers, 'Content-type: text/xml; charset=iso-8859-1');
     $this->assertEquals(200, $response->statusCode);
     $msg = XmlRpcResponseMessage::fromString($response->getContent());
     $data = $msg->getData();
     $this->assertEquals('Lalala', $data[0]);
     $this->assertEquals(1, $data[1]);
     $this->assertEquals(array(12, 'Egypt', FALSE, -31), $data[2]);
     $this->assertEquals(array('lowerBound' => 18, 'upperBound' => 139), $data[3]);
 }