response.setContentType("text/xml; charset=UTF-8");
response.setContentType(DEFAULT_CONTENT_TYPE); messageLogger.logDebug("Response content type is '" + DEFAULT_CONTENT_TYPE + "'");
    public void doGet(final HttpServletRequest request, final HttpServletResponse response) {        /* Avoid null-pointer exceptions. */        if (request == null) {            messageLogger.logCritical("Response object cannot be null", new NullPointerException("request is null"));            return;        }        if (response == null) {            messageLogger.logCritical("Response object cannot be null", new NullPointerException("response is null"));            return;        }        /* The access point to the web services */        AxisEngine axisEngine = null;        /* The object representing the requested web service */        SOAPService service = null;        /* Writer for response */        PrintWriter printWriter = null;        /* Get writer for the WSDL output (XML) */        try {            printWriter = response.getWriter();        } catch (IOException ioe) {            handleException("Unable to get response writer", ioe, request, response);            return;        }        /* Retrieve axis engine */        try {            axisEngine = getEngine();        } catch (AxisFault fault) {            handleException("Unable to get AxisEngine", fault, request, response);            return;        }        /* Context used by the axis engine to handle the request */        MessageContext messageContext = createMessageContext(axisEngine, request, response);        /* Set the username given in the request. */        messageContext.setUsername(request.getRemoteUser());        /* Identify service. */        String serviceName = request.getServletPath();        try {            service = axisEngine.getService(serviceName);        } catch (AxisFault fault) {            handleException("Unable to get SOAPService", fault, request, response);            return;        }        /* Make NullPointerException page and return if service is null */        if (service == null) {            handleException("No SOAPService object returned", new NullPointerException("service is null"), request, response);            return;        }        /* Add service to message context */        try {            messageContext.setService(service);        } catch (AxisFault af) {            handleException("Unable to set SOAPService in messageContext", af, request, response);            return;        }        /* Identify type of response (HTML or WSDL) */        String queryString = request.getQueryString();        /*         * Return WSDL if correct query string has been given, otherwise return         * simple HTML page         */        if (queryString != null && queryString.equalsIgnoreCase("wsdl")) {            /* XML document object to hold the returned WSDL data */            Document wsdl = null;            /* Get the service to generate the WSDL */            try {                service.generateWSDL(messageContext);            } catch (AxisFault af) {                handleException("Unable to generate WSDL", af, request, response);                return;            }            /* The generated XML is put into the context */            Object object = messageContext.getProperty("WSDL");            if (object instanceof Document)                wsdl = (Document) object;            /* Make exception page and return if the WSDL data was not generated */            if (wsdl == null) {                handleException("No WSDL data available", new NullPointerException("wsdl is null"), request, response);                return;            }            /* Serialize DOM to XML string */            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();            XMLSerializer xmlSerializer = new XMLSerializer();            xmlSerializer.setOutputByteStream(outputStream);            /* Log and return if serialization fails */            try {                xmlSerializer.serialize(wsdl);            } catch (IOException ioe) {                handleException("Unable to serialize WSDL", ioe, request, response);                return;            }            /* Print result to client */            response.setCharacterEncoding("UTF-8");            response.setContentType("text/xml; charset=UTF-8");            printWriter.print(outputStream.toString());        } else {            /* Get JSP for handling HTML output */            RequestDispatcher requestDispatcher = request.getSession().getServletContext().getNamedDispatcher("Axis.JSP");            /* Set the service name as attribute for the JSP */            request.setAttribute("serviceName", serviceName);            /* Log and return if dispatch fails */            try {                requestDispatcher.forward(request, response);            } catch (Exception e) {                //handleException("Unable to dispatch request to " +                // jspLocation + "/Axis.JSP", e, request, response);                return;            }        }    }