protected function returnValidXml($data)
    {
        if (empty($data)) {
            throw new common_exception_NotFound('Delivery execution not found.');
        }

        $doc = @simplexml_load_string($data);
        if (!$doc) {
            common_Logger::i('invalid xml result');
            throw new Exception('Xml output is malformed.');
        }

        // force XML content type header
        header('Content-Type: application/xml');

        echo $data;
        exit(0);
    }