Object context = msgContext.getProperty(Constants.MC_SERVLET_ENDPOINT_CONTEXT); if (context instanceof ServletEndpointContext) { ServletEndpointContext servletEndpointContext = (ServletEndpointContext) context; ServletContext servletCtx = servletEndpointContext.getServletContext(); webAppCtx = (WebApplicationContext) servletCtx .getAttribute(SpringAxisServlet.SERVLET_CONTEXT_ATTRIBUTE); if (webAppCtx == null) { throw new ServiceException( "Cannot find SpringAxisServlet's WebApplicationContext" + " as ServletContext attribute [" + SpringAxisServlet.SERVLET_CONTEXT_ATTRIBUTE + "]");
if (msgContext != null) { Object context = msgContext.getProperty(Constants.MC_SERVLET_ENDPOINT_CONTEXT); if (context instanceof ServletEndpointContext) { ServletEndpointContext servletEndpointContext = (ServletEndpointContext) context; ServletContext servletCtx = servletEndpointContext.getServletContext(); webAppCtx = WebApplicationContextUtils.getWebApplicationContext(servletCtx); if (webAppCtx == null) { log.info("failed to retrieve webapp context for spring-axis integration"); throw new ServiceException( "Cannot find WebApplicationContext from org.springframework.web.context.ContextLoaderListener"); } } else { log.info("failed to retrieve webapp context for spring-axis integration because this is an incorrect servlet context!"); throw new ServiceException("Invalid context - expected [" + ServletEndpointContext.class.getName() + "], actual [" + context + "]");
    private void initWebAppContext(MessageContext msgContext) throws ServiceException {        if (webAppCtx == null) {            Object context = msgContext.getProperty(Constants.MC_SERVLET_ENDPOINT_CONTEXT);            if (context instanceof ServletEndpointContext) {                ServletEndpointContext servletEndpointContext = (ServletEndpointContext) context;                ServletContext servletCtx = servletEndpointContext.getServletContext();                webAppCtx = (WebApplicationContext) servletCtx                    .getAttribute(SpringAxisServlet.SERVLET_CONTEXT_ATTRIBUTE);                if (webAppCtx == null) {                    throw new ServiceException(                        "Cannot find SpringAxisServlet's WebApplicationContext"                                + " as ServletContext attribute ["                                + SpringAxisServlet.SERVLET_CONTEXT_ATTRIBUTE                                + "]");                }            } else {                throw new ServiceException("Invalid context - expected ["                        + ServletEndpointContext.class.getName()                        + "], actual ["                        + context                        + "]");            }        }    }