/**
  * 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 = \webservices\xmlrpc\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 \lang\IllegalAccessException('Authorization required: ' . $response->getHeader('WWW-Authenticate'));
         default:
             throw new \lang\IllegalStateException('Unexpected return code: ' . $response->getStatusCode());
     }
 }
 public function multipleParameters()
 {
     $this->router->setMockData('<?xml version="1.0" encoding="utf-8"?>
   <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=utf-8');
     $this->assertEquals(200, $response->statusCode);
     $msg = \webservices\xmlrpc\XmlRpcResponseMessage::fromString($response->getContent());
     $data = $msg->getData();
     $this->assertEquals('Lalala', $data[0]);
     $this->assertEquals(1, $data[1]);
     $this->assertEquals([12, 'Egypt', false, -31], $data[2]);
     $this->assertEquals(['lowerBound' => 18, 'upperBound' => 139], $data[3]);
 }