Search in sources :

Example 1 with HttpResponseInfoImpl

use of org.glassfish.webservices.monitoring.HttpResponseInfoImpl in project Payara by payara.

the class JAXRPCServlet method doPost.

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    WebServiceEngineImpl wsEngine = WebServiceEngineImpl.getInstance();
    if ("Tester".equalsIgnoreCase(request.getQueryString())) {
        Endpoint endpt = wsEngine.getEndpoint(request.getServletPath());
        if (endpt != null && Boolean.parseBoolean(endpt.getDescriptor().getDebugging())) {
            WebServiceTesterServlet.invoke(request, response, endpt.getDescriptor());
            return;
        }
    }
    if (delegate != null) {
        // check if we need to trace this...
        String messageId = null;
        if (wsEngine.getGlobalMessageListener() != null) {
            Endpoint endpt = wsEngine.getEndpoint(request.getServletPath());
            messageId = wsEngine.preProcessRequest(endpt);
            if (messageId != null) {
                ThreadLocalInfo config = new ThreadLocalInfo(messageId, request);
                wsEngine.getThreadLocal().set(config);
            }
        }
        delegate.doPost(request, response);
        if (messageId != null) {
            wsEngine.postProcessResponse(messageId, new HttpResponseInfoImpl(response));
        }
    }
}
Also used : Endpoint(org.glassfish.webservices.monitoring.Endpoint) ThreadLocalInfo(org.glassfish.webservices.monitoring.ThreadLocalInfo) HttpResponseInfoImpl(org.glassfish.webservices.monitoring.HttpResponseInfoImpl) WebServiceEngineImpl(org.glassfish.webservices.monitoring.WebServiceEngineImpl)

Example 2 with HttpResponseInfoImpl

use of org.glassfish.webservices.monitoring.HttpResponseInfoImpl in project Payara by payara.

the class EjbWebServiceDispatcher method handlePost.

private void handlePost(HttpServletRequest req, HttpServletResponse resp, EjbRuntimeEndpointInfo endpointInfo) throws IOException, SOAPException {
    JAXRPCEndpointImpl endpoint = null;
    String messageID = null;
    SOAPMessageContext msgContext = null;
    try {
        MimeHeaders headers = wsUtil.getHeaders(req);
        if (!wsUtil.hasTextXmlContentType(headers)) {
            wsUtil.writeInvalidContentType(resp);
            return;
        }
        msgContext = jaxRpcObjectFactory.createSOAPMessageContext();
        SOAPMessage message = createSOAPMessage(req, headers);
        boolean wssSucceded = true;
        if (message != null) {
            msgContext.setMessage(message);
            // get the endpoint info
            endpoint = (JAXRPCEndpointImpl) endpointInfo.getEndpoint().getExtraAttribute(EndpointImpl.NAME);
            if (endpoint != null) {
                // first global notification
                if (wsEngine.hasGlobalMessageListener()) {
                    messageID = wsEngine.preProcessRequest(endpoint);
                }
            } else {
                if (logger.isLoggable(FINE)) {
                    logger.log(FINE, MISSING_MONITORING_INFO, req.getRequestURI());
                }
            }
            AdapterInvocationInfo adapterInvocationInfo = null;
            if (!(endpointInfo instanceof Ejb2RuntimeEndpointInfo)) {
                throw new IllegalArgumentException(endpointInfo + "is not instance of Ejb2RuntimeEndpointInfo.");
            }
            try {
                Ejb2RuntimeEndpointInfo endpointInfo2 = (Ejb2RuntimeEndpointInfo) endpointInfo;
                // Do ejb container pre-invocation and pre-handler logic
                adapterInvocationInfo = endpointInfo2.getHandlerImplementor();
                // Set message context in invocation
                EJBInvocation.class.cast(adapterInvocationInfo.getInv()).setMessageContext(msgContext);
                // Set http response object so one-way operations will
                // response before actual business method invocation.
                msgContext.setProperty(HTTP_SERVLET_RESPONSE, resp);
                if (securityService != null) {
                    wssSucceded = securityService.validateRequest(endpointInfo2.getServerAuthConfig(), (StreamingHandler) adapterInvocationInfo.getHandler(), msgContext);
                }
                // Trace if necessary
                if (messageID != null || (endpoint != null && endpoint.hasListeners())) {
                    // create the thread local
                    ThreadLocalInfo threadLocalInfo = new ThreadLocalInfo(messageID, req);
                    wsEngine.getThreadLocal().set(threadLocalInfo);
                    if (endpoint != null) {
                        endpoint.processRequest(msgContext);
                    } else {
                        if (logger.isLoggable(FINE)) {
                            logger.log(FINE, MISSING_MONITORING_INFO, req.getRequestURI());
                        }
                    }
                }
                // which will be flow back into the EJB container.
                if (wssSucceded) {
                    adapterInvocationInfo.getHandler().handle(msgContext);
                }
            } finally {
                // preInvoke steps might have occurred. It's ok if implementor is null.
                if (adapterInvocationInfo != null) {
                    endpointInfo.releaseImplementor(adapterInvocationInfo.getInv());
                }
            }
        } else {
            String errorMsg = MessageFormat.format(logger.getResourceBundle().getString(NULL_MESSAGE), endpointInfo.getEndpoint().getEndpointName(), endpointInfo.getEndpointAddressUri());
            if (logger.isLoggable(Level.FINE)) {
                logger.fine(errorMsg);
            }
            msgContext.writeSimpleErrorResponse(FAULT_CODE_CLIENT, errorMsg);
        }
        if (messageID != null || endpoint != null) {
            endpoint.processResponse(msgContext);
        }
        SOAPMessage reply = msgContext.getMessage();
        if (securityService != null && wssSucceded) {
            if (!(endpointInfo instanceof Ejb2RuntimeEndpointInfo)) {
                throw new IllegalArgumentException(endpointInfo + "is not instance of Ejb2RuntimeEndpointInfo.");
            }
            Ejb2RuntimeEndpointInfo endpointInfo2 = (Ejb2RuntimeEndpointInfo) endpointInfo;
            securityService.secureResponse(endpointInfo2.getServerAuthConfig(), (StreamingHandler) endpointInfo2.getHandlerImplementor().getHandler(), msgContext);
        }
        if (reply.saveRequired()) {
            reply.saveChanges();
        }
        wsUtil.writeReply(resp, msgContext);
    } catch (Throwable e) {
        String errorMessage = MessageFormat.format(logger.getResourceBundle().getString(ERROR_ON_EJB), new Object[] { endpointInfo.getEndpoint().getEndpointName(), endpointInfo.getEndpointAddressUri(), e.getMessage() });
        logger.log(WARNING, errorMessage, e);
        SOAPMessageContext errorMsgContext = jaxRpcObjectFactory.createSOAPMessageContext();
        errorMsgContext.writeSimpleErrorResponse(FAULT_CODE_SERVER, errorMessage);
        resp.setStatus(SC_INTERNAL_SERVER_ERROR);
        if (messageID != null || endpoint != null) {
            endpoint.processResponse(errorMsgContext);
        }
        wsUtil.writeReply(resp, errorMsgContext);
    }
    // Final tracing notification
    if (messageID != null) {
        HttpResponseInfoImpl response = new HttpResponseInfoImpl(resp);
        wsEngine.postProcessResponse(messageID, response);
    }
}
Also used : StreamingHandler(com.sun.xml.rpc.spi.runtime.StreamingHandler) HttpResponseInfoImpl(org.glassfish.webservices.monitoring.HttpResponseInfoImpl) SOAPMessage(javax.xml.soap.SOAPMessage) MimeHeaders(javax.xml.soap.MimeHeaders) SOAPMessageContext(com.sun.xml.rpc.spi.runtime.SOAPMessageContext) EJBInvocation(org.glassfish.ejb.api.EJBInvocation) ThreadLocalInfo(org.glassfish.webservices.monitoring.ThreadLocalInfo) JAXRPCEndpointImpl(org.glassfish.webservices.monitoring.JAXRPCEndpointImpl)

Example 3 with HttpResponseInfoImpl

use of org.glassfish.webservices.monitoring.HttpResponseInfoImpl in project Payara by payara.

the class MonitoringPipe method firePostInvocation.

private void firePostInvocation(HttpServletResponse httpResponse, Packet pipeResponse, Packet pipeRequest, JAXWSEndpointImpl endpointTracer, SOAPMessageContextImpl soapMessageContext) {
    if (seiModel instanceof SOAPSEIModel) {
        SOAPSEIModel soapSEIModel = (SOAPSEIModel) seiModel;
        Globals.get(MonitorFilter.class).filterResponse(pipeRequest, pipeResponse, new MonitorContextImpl(soapSEIModel.getDatabinding().deserializeRequest(pipeRequest), soapSEIModel, wsdlModel, ownerEndpoint, endpoint));
    }
    // Make the response packet available in the MessageContext
    soapMessageContext.setPacket(pipeResponse);
    try {
        // Invoke processRequest on global and local listeners
        endpointTracer.processResponse(soapMessageContext);
    } catch (Exception e) {
    // temporary - need to send back SOAP fault message
    }
    String messageTraceId = (String) soapMessageContext.get(MESSAGE_ID);
    if (messageTraceId != null) {
        wsMonitor.postProcessResponse(messageTraceId, new HttpResponseInfoImpl(httpResponse));
    }
}
Also used : MonitorContextImpl(org.glassfish.webservices.monitoring.MonitorContextImpl) SOAPSEIModel(com.sun.xml.ws.model.SOAPSEIModel) HttpResponseInfoImpl(org.glassfish.webservices.monitoring.HttpResponseInfoImpl) MonitorFilter(org.glassfish.webservices.monitoring.MonitorFilter)

Aggregations

HttpResponseInfoImpl (org.glassfish.webservices.monitoring.HttpResponseInfoImpl)3 ThreadLocalInfo (org.glassfish.webservices.monitoring.ThreadLocalInfo)2 SOAPMessageContext (com.sun.xml.rpc.spi.runtime.SOAPMessageContext)1 StreamingHandler (com.sun.xml.rpc.spi.runtime.StreamingHandler)1 SOAPSEIModel (com.sun.xml.ws.model.SOAPSEIModel)1 MimeHeaders (javax.xml.soap.MimeHeaders)1 SOAPMessage (javax.xml.soap.SOAPMessage)1 EJBInvocation (org.glassfish.ejb.api.EJBInvocation)1 Endpoint (org.glassfish.webservices.monitoring.Endpoint)1 JAXRPCEndpointImpl (org.glassfish.webservices.monitoring.JAXRPCEndpointImpl)1 MonitorContextImpl (org.glassfish.webservices.monitoring.MonitorContextImpl)1 MonitorFilter (org.glassfish.webservices.monitoring.MonitorFilter)1 WebServiceEngineImpl (org.glassfish.webservices.monitoring.WebServiceEngineImpl)1