⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 axisservlet.java

📁 Java有关XML编程需要用到axis 的源代码 把里面bin下的包导入相应的Java工程 进行使用
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                writer.println("<p>" +                               Messages.getMessage("transportName00",                        "<b>" + transportName + "</b>"));                writer.println("</html>");            }        } catch (AxisFault fault) {            reportTroubleInGet(fault, response, writer);        } catch (Exception e) {            reportTroubleInGet(e, response, writer);        } finally {            writer.close();            if (isDebug) {                log.debug("Exit: doGet()");            }        }    }    /**     * when we get an exception or an axis fault in a GET, we handle     * it almost identically: we go 'something went wrong', set the response     * code to 500 and then dump info. But we dump different info for an axis fault     * or subclass thereof.     * @param exception what went wrong     * @param response current response     * @param writer open writer to response     */    private void reportTroubleInGet(Throwable exception,                                    HttpServletResponse response,                                    PrintWriter writer) {        response.setContentType("text/html; charset=utf-8");        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);        writer.println("<h2>" +                       Messages.getMessage("error00") +                       "</h2>");        writer.println("<p>" +                       Messages.getMessage("somethingWrong00") +                       "</p>");        if (exception instanceof AxisFault) {            AxisFault fault = (AxisFault) exception;            processAxisFault(fault);            writeFault(writer, fault);        } else {            logException(exception);            writer.println("<pre>Exception - " + exception + "<br>");            //dev systems only give fault dumps            if (isDevelopment()) {                writer.println(JavaUtils.stackToString(exception));            }            writer.println("</pre>");        }    }    /**     * routine called whenever an axis fault is caught; where they     * are logged and any other business. The method may modify the fault     * in the process     * @param fault what went wrong.     */    protected void processAxisFault(AxisFault fault) {        //log the fault        Element runtimeException = fault.lookupFaultDetail(                Constants.QNAME_FAULTDETAIL_RUNTIMEEXCEPTION);        if (runtimeException != null) {            exceptionLog.info(Messages.getMessage("axisFault00"), fault);            //strip runtime details            fault.removeFaultDetail(Constants.                                    QNAME_FAULTDETAIL_RUNTIMEEXCEPTION);        } else if (exceptionLog.isDebugEnabled()) {            exceptionLog.debug(Messages.getMessage("axisFault00"), fault);        }        //dev systems only give fault dumps        if (!isDevelopment()) {            //strip out the stack trace            fault.removeFaultDetail(Constants.QNAME_FAULTDETAIL_STACKTRACE);        }    }    /**     * log any exception to our output log, at our chosen level     * @param e what went wrong     */    protected void logException(Throwable e) {        exceptionLog.info(Messages.getMessage("exception00"), e);    }    /**     * this method writes a fault out to an HTML stream. This includes     * escaping the strings to defend against cross-site scripting attacks     * @param writer     * @param axisFault     */    private void writeFault(PrintWriter writer, AxisFault axisFault) {        String localizedMessage = XMLUtils.xmlEncodeString(axisFault.                getLocalizedMessage());        writer.println("<pre>Fault - " + localizedMessage + "<br>");        writer.println(axisFault.dumpToString());        writer.println("</pre>");    }    /**     * print a snippet of service info.     * @param service service     * @param writer output channel     * @param serviceName where to put stuff     */    protected void reportServiceInfo(HttpServletResponse response,                                     PrintWriter writer, SOAPService service,                                     String serviceName) {        response.setContentType("text/html; charset=utf-8");        writer.println("<h1>"                       + service.getName()                       + "</h1>");        writer.println(                "<p>" +                Messages.getMessage("axisService00") +                "</p>");        writer.println(                "<i>" +                Messages.getMessage("perhaps00") +                "</i>");    }    /**     * report that we have no WSDL     *     * This method was moved to the querystring handler QSWSDLHandler. The     * method reportNoWSDL in AxisServlet is never called. Perhaps the method     * is overwritten in subclasses of AxisServlet so the method wasn't     * removed. See the discussion in     *     * http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23845     *     * @param res     * @param writer     * @param moreDetailCode optional name of a message to provide more detail     * @param axisFault optional fault string, for extra info at debug time only     */    protected void reportNoWSDL(HttpServletResponse res, PrintWriter writer,                                String moreDetailCode, AxisFault axisFault) {    }    /**     * This method lists the available services; it is called when there is     * nothing to execute on a GET     * @param response     * @param writer     * @param request     * @throws ConfigurationException     * @throws AxisFault     */    protected void reportAvailableServices(HttpServletResponse response,                                           PrintWriter writer,                                           HttpServletRequest request) throws            ConfigurationException, AxisFault {        AxisEngine engine = getEngine();        response.setContentType("text/html; charset=utf-8");        writer.println("<h2>And now... Some Services</h2>");        Iterator i;        try {            i = engine.getConfig().getDeployedServices();        } catch (ConfigurationException configException) {            //turn any internal configuration exceptions back into axis faults            //if that is what they are            if (configException.getContainedException() instanceof AxisFault) {                throw (AxisFault) configException.getContainedException();            } else {                throw configException;            }        }        // baseURL may change if <endpointURL> tag is used for        // custom deployment at a different location        String defaultBaseURL = getWebappBase(request) + servicesPath;        writer.println("<ul>");        while (i.hasNext()) {            ServiceDesc sd = (ServiceDesc) i.next();            StringBuffer sb = new StringBuffer();            sb.append("<li>");            String name = sd.getName();            sb.append(name);            sb.append(" <a href=\"");            String endpointURL = sd.getEndpointURL();            String baseURL = (endpointURL == null) ? defaultBaseURL :                             endpointURL;            sb.append(baseURL);            sb.append(name);            sb.append("?wsdl\"><i>(wsdl)</i></a></li>");            writer.println(sb.toString());            ArrayList operations = sd.getOperations();            if (!operations.isEmpty()) {                writer.println("<ul>");                for (Iterator it = operations.iterator(); it.hasNext(); ) {                    OperationDesc desc = (OperationDesc) it.next();                    writer.println("<li>" + desc.getName());                }                writer.println("</ul>");            }        }        writer.println("</ul>");    }    /**     * generate the error response to indicate that there is apparently no endpoint there     * @param request the request that didnt have an edpoint     * @param response response we are generating     * @param writer open writer for the request     */    protected void reportCantGetAxisService(HttpServletRequest request,                                            HttpServletResponse response,                                            PrintWriter writer) {        // no such service....        response.setStatus(HttpURLConnection.HTTP_NOT_FOUND);        response.setContentType("text/html; charset=utf-8");        writer.println("<h2>" +                       Messages.getMessage("error00") + "</h2>");        writer.println("<p>" +                       Messages.getMessage("noService06") +                       "</p>");    }    /**     * probe for a JWS page and report 'no service' if one is not found there     * @param request the request that didnt have an edpoint     * @param response response we are generating     * @param writer open writer for the request     */    protected void reportCantGetJWSService(HttpServletRequest request,                                           HttpServletResponse response,                                           PrintWriter writer) {        // first look to see if there is a service        // requestPath is a work around to support serving .jws web services        // from services URL - see AXIS-843 for more information        String requestPath = request.getServletPath() + ((request.getPathInfo() != null) ?                request.getPathInfo() : "");        String realpath = getServletConfig().getServletContext()                          .getRealPath(requestPath);        log.debug("JWS real path: " + realpath);        boolean foundJWSFile = (new File(realpath).exists()) &&                               (realpath.endsWith(Constants.                                                  JWS_DEFAULT_FILE_EXTENSION));        response.setContentType("text/html; charset=utf-8");        if (foundJWSFile) {            response.setStatus(HttpURLConnection.HTTP_OK);            writer.println(Messages.getMessage("foundJWS00") + "<p>");            String url = request.getRequestURI();            String urltext = Messages.getMessage("foundJWS01");            writer.println("<a href='" + url + "?wsdl'>" + urltext + "</a>");        } else {            response.setStatus(HttpURLConnection.HTTP_NOT_FOUND);            writer.println(Messages.getMessage("noService06"));        }    }    /**     * Process a POST to the servlet by handing it off to the Axis Engine.     * Here is where SOAP messages are received     * @param req posted request     * @param res respose     * @throws ServletException trouble     * @throws IOException different trouble     */    public void doPost(HttpServletRequest req, HttpServletResponse res) throws            ServletException, IOException {        long t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0;        String soapAction = null;        MessageContext msgContext = null;        if (isDebug) {            log.debug("Enter: doPost()");        }        if (tlog.isDebugEnabled()) {            t0 = System.currentTimeMillis();        }        Message responseMsg = null;        String contentType = null;        try {            AxisEngine engine = getEngine();            if (engine == null) {                // !!! should return a SOAP fault...                ServletException se =                        new ServletException(Messages.getMessage("noEngine00"));                log.debug("No Engine!", se);                throw se;            }            res.setBufferSize(1024 * 8); // provide performance boost.            /** get message context w/ various properties set             */            msgContext = createMessageContext(engine, req, res);            // ? OK to move this to 'getMessageContext',            // ? where it would also be picked up for 'doGet()' ?            if (securityProvider != null) {                if (isDebug) {                    log.debug("securityProvider:" + securityProvider);                }                msgContext.setProperty(MessageContext.SECURITY_PROVIDER,                                       securityProvider);            }            /* Get request message             */            Message requestMsg =                    new Message(req.getInputStream(),                                false,                                req.getHeader(HTTPConstants.HEADER_CONTENT_TYPE),                                req.getHeader(HTTPConstants.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -