public function encodeCall($method, $data = array()) {

        $xml = new XMLWriter(); 

        $xml->openMemory();

        $xml->setIndent(false);

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

        $xml->startElement("methodCall");

            $xml->writeElement("methodName", trim($method));

            $xml->startElement("params");

            try {
                        
                foreach ( $data as $d ) {

                    $xml->startElement("param");

                        $xml->startElement("value");

                            $this->encodeValue($xml, $d);

                        $xml->endElement();

                    $xml->endElement();

                }

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

            }

            $xml->endElement();

        $xml->endElement();

        $xml->endDocument();

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

    }