public function encodeResponse($data) {

        $xml = new XMLWriter(); 

        $xml->openMemory();

        $xml->setIndent(false);

        $xml->startDocument('1.0', $this->encoding); 

        $xml->startElement("methodResponse");

            $xml->startElement("params");

                $xml->startElement("param");

                    $xml->startElement("value");

                    try {
                    
                        $this->encodeValue($xml, $data);

                    } catch (XmlrpcException $xe) {
                        
                        throw $xe;

                    } catch (Exception $e) {
                        
                        throw $e;

                    }

                    $xml->endElement();

                $xml->endElement();

            $xml->endElement();

        $xml->endElement();

        $xml->endDocument();

        return trim($xml->outputMemory());

    }