Package org.apache.axis2.jaxws.core

Examples of org.apache.axis2.jaxws.core.MessageContext


            //We'll need an instance of the EndpointController to actually
            //drive the invocation.
            //TODO: More work needed to determine the lifecycle of this thing
            EndpointController endpointCtlr = new EndpointController();

            MessageContext requestMsgCtx = new MessageContext(axisRequestMsgCtx);
            requestMsgCtx.setMEPContext(new MEPContext(requestMsgCtx));
            // The adapters need to be installed on the new request Message Context
            AttachmentsAdapter.install(requestMsgCtx);
            TransportHeadersAdapter.install(requestMsgCtx);
           
            Binding binding = (Binding)axisRequestMsgCtx.getProperty(PARAM_BINDING);
            InvocationContext ic = InvocationContextFactory.createInvocationContext(binding);
            ic.setRequestMessageContext(requestMsgCtx);

            //TODO:Once we the JAX-WS MessageContext one of the next things that
            //needs to be done here is setting up all of the javax.xml.ws.*
            //properties for the MessageContext.

            ic = endpointCtlr.invoke(ic);
            MessageContext responseMsgCtx = ic.getResponseMessageContext();

            //If there is a fault it could be Robust In-Only
            if (!isMepInOnly(mep) || hasFault(responseMsgCtx)) {
                // If this is a two-way exchange, there should already be a
                // JAX-WS MessageContext for the response.  We need to pull
                // the Message data out of there and set it on the Axis2
                // MessageContext.
                org.apache.axis2.context.MessageContext axisResponseMsgCtx =
                        responseMsgCtx.getAxisMessageContext();

                MessageUtils.putMessageOnMessageContext(responseMsgCtx.getMessage(),
                                                        axisResponseMsgCtx);

                OperationContext opCtx = axisResponseMsgCtx.getOperationContext();
                opCtx.addMessageContext(axisResponseMsgCtx);

                // If this is a fault message, we want to throw it as an
                // exception so that the transport can do the appropriate things
                if (responseMsgCtx.getMessage().isFault()) {
                   
                    //Rather than create a new AxisFault, we should use the AxisFault that was
                    //created at the causedBy
                    if (responseMsgCtx.getCausedByException() != null)
                        faultToReturn = responseMsgCtx.getCausedByException();
                    else {
                        faultToReturn = new AxisFault("An error was detected during JAXWS processing",
                                                          axisResponseMsgCtx);
                    }
                } else {
View Full Code Here


     * This method is used to start the JAX-WS invocation of a target endpoint. It takes an
     * InvocationContext, which must have a MessageContext specied for the request.  Once the
     * invocation is complete, the information will be stored
     */
    public InvocationContext invoke(InvocationContext ic) {
        MessageContext requestMsgCtx = ic.getRequestMessageContext();

        String implClassName = getServiceImplClassName(requestMsgCtx);

        Class implClass = loadServiceImplClass(implClassName,
                                               requestMsgCtx.getClassLoader());

        EndpointDescription endpointDesc = getEndpointDescription(requestMsgCtx, implClass);
        requestMsgCtx.setEndpointDescription(endpointDesc);

        /*
         * TODO: review: make sure the handlers are set on the InvocationContext
         * This implementation of the JAXWS runtime does not use Endpoint, which
         * would normally be the place to initialize and store the handler list.
         * In lieu of that, we will have to intialize and store them on the
         * InvocationContext.  also see the InvocationContextFactory.  On the client
         * side, the binding is not yet set when we call into that factory, so the
         * handler list doesn't get set on the InvocationContext object there.  Thus
         * we gotta do it here.
         *
         * Since we're on the server, and there apparently is no Binding object
         * anywhere to be found...
         */
        if (ic.getHandlers() == null) {
            ic.setHandlers(new HandlerResolverImpl(endpointDesc.getServiceDescription()).getHandlerChain(endpointDesc.getPortInfo()));
        }

        if (!bindingTypesMatch(requestMsgCtx, endpointDesc.getServiceDescription())) {
            Protocol protocol = requestMsgCtx.getMessage().getProtocol();
            // only if protocol is soap12 and MISmatches the endpoint do we halt processing
            if (protocol.equals(Protocol.soap12)) {
                ic.setResponseMessageContext(createMismatchFaultMsgCtx(requestMsgCtx,
                                                                       "Incoming SOAP message protocol is version 1.2, but endpoint is configured for SOAP 1.1"));
                return ic;
            } else if (protocol.equals(Protocol.soap11)) {
                // SOAP 1.1 message and SOAP 1.2 binding

                // The canSupport flag indicates that we can support this scenario.
                // Possible Examples of canSupport:  JAXB impl binding, JAXB Provider
                // Possible Example of !canSupport: Application handler usage, non-JAXB Provider
                // Initially I vote to hard code this as false.
                boolean canSupport = false;
                if (canSupport) {
                    // TODO: Okay, but we need to scrub the Message create code to make sure that the response message
                    // is always built from the receiver protocol...not the binding protocol
                } else {
                    ic.setResponseMessageContext(createMismatchFaultMsgCtx(requestMsgCtx,
                                                                           "Incoming SOAP message protocol is version 1.1, but endpoint is configured for SOAP 1.2.  This is not supported."));
                    return ic;
                }
            } else {
                ic.setResponseMessageContext(createMismatchFaultMsgCtx(requestMsgCtx,
                                                                       "Incoming message protocol does not match endpoint protocol."));
                return ic;
            }
        }

        MessageContext responseMsgContext = null;

        try {
            // Get the service instance.  This will run the @PostConstruct code.
            EndpointLifecycleManager elm = createEndpointlifecycleManager();
            Object serviceInstance = elm.createServiceInstance(requestMsgCtx, implClass);

            // The application handlers and dispatcher invoke will
            // modify/destroy parts of the message.  Make sure to save
            // the request message if appropriate.
            saveRequestMessage(requestMsgCtx);

            // Invoke inbound application handlers.  It's safe to use the first object on the iterator because there is
            // always exactly one EndpointDescription on a server invoke
            boolean success =
                    HandlerInvokerUtils.invokeInboundHandlers(requestMsgCtx.getMEPContext(),
                                                              ic.getHandlers(),
                                                              HandlerChainProcessor.MEP.REQUEST,
                                                              isOneWay(requestMsgCtx.getAxisMessageContext()));

            if (success) {

                // Dispatch to the
                EndpointDispatcher dispatcher = getEndpointDispatcher(implClass, serviceInstance);
                try {
                    responseMsgContext = dispatcher.invoke(requestMsgCtx);
                } finally {
                    // Passed pivot point
                    requestMsgCtx.getMessage().setPostPivot();
                }

                // Invoke the outbound response handlers.
                // If the message is one way, we should not invoke the response handlers.  There is no response
                // MessageContext since a one way invocation is considered to have a "void" return.
                if (!isOneWay(requestMsgCtx.getAxisMessageContext())) {
                    responseMsgContext.setMEPContext(requestMsgCtx.getMEPContext());
                   
                    HandlerInvokerUtils.invokeOutboundHandlers(responseMsgContext.getMEPContext(),
                                                               ic.getHandlers(),
                                                               HandlerChainProcessor.MEP.RESPONSE,
                                                               false);
                }
            } else
            { // the inbound handler chain must have had a problem, and we've reversed directions
                responseMsgContext =
                        MessageContextUtils.createResponseMessageContext(requestMsgCtx);
                // since we've reversed directions, the message has "become a response message" (section 9.3.2.1, footnote superscript 2)
                responseMsgContext.setMessage(requestMsgCtx.getMessage());
            }

        } catch (Exception e) {
            // TODO for now, throw it.  We probably should try to make an XMLFault object and set it on the message
            throw ExceptionFactory.makeWebServiceException(e);
View Full Code Here

            XMLFault xmlfault =
                    new XMLFault(XMLFaultCode.VERSIONMISMATCH, new XMLFaultReason(errorMsg));
            Message msg = ((MessageFactory)FactoryRegistry.getFactory(MessageFactory.class))
                    .create(Protocol.soap11)// always soap11 according to the spec
            msg.setXMLFault(xmlfault);
            MessageContext responseMsgCtx =
                    MessageContextUtils.createFaultMessageContext(requestMsgCtx);
            responseMsgCtx.setMessage(msg);
            return responseMsgCtx;
        } catch (XMLStreamException e) {
            // Need to fix this !   At least provide logging
            // TODO for now, throw it.  We probably should try to make an XMLFault object and set it on the message
            throw ExceptionFactory.makeWebServiceException(e);
View Full Code Here

        return AsyncUtils.createJAXWSMessageContext(result.getResponseMessageContext());
    }

    public static MessageContext createJAXWSMessageContext(
            org.apache.axis2.context.MessageContext mc) throws WebServiceException {
        MessageContext response = null;

        if (debug) {
            log.debug("Creating response MessageContext");
        }

        // Create the JAX-WS response MessageContext from the Axis2 response
        response = new MessageContext(mc);
        // don't set the response.setMEPContext() here.

        // REVIEW: Are we on the final thread of execution here or does this get handed off to the executor?
        // TODO: Remove workaround for WS-Addressing running in thin client (non-server) environment
        try {
View Full Code Here

        boolean debug = log.isDebugEnabled();
        if (debug) {
            log.debug("JAX-WS async response listener received the response");
        }

        MessageContext responseMsgCtx = null;
        try {
            responseMsgCtx = AsyncUtils.createJAXWSMessageContext(result);
            responseMsgCtx.setInvocationContext(invocationCtx);
            // make sure request and response contexts share a single parent
            responseMsgCtx.setMEPContext(invocationCtx.getRequestMessageContext().getMEPContext());
        } catch (WebServiceException e) {
            response.onError(e, null);
            if (debug) {
                log.debug(
                        "An error occured while processing the async response.  " + e.getMessage());
View Full Code Here

        // If a SOAPFault was returned by the AxisEngine, the AxisFault
        // that is returned should have a MessageContext with it.  Use
        // this to unmarshall the fault included there.
        if (e.getClass().isAssignableFrom(AxisFault.class)) {
            AxisFault fault = (AxisFault)e;
            MessageContext faultMessageContext = null;
            try {
                faultMessageContext =
                        AsyncUtils.createJAXWSMessageContext(fault.getFaultMessageContext());
                faultMessageContext.setInvocationContext(invocationCtx);
                // make sure request and response contexts share a single parent
                faultMessageContext.setMEPContext(invocationCtx.getRequestMessageContext().getMEPContext());
            } catch (WebServiceException wse) {
                response.onError(wse, null);
            }

            response.onError(e, faultMessageContext);
View Full Code Here

        HandlerChainProcessor processor1 = new HandlerChainProcessor(null, Protocol.soap11);
        HandlerChainProcessor processor2 =
                new HandlerChainProcessor(new ArrayList<Handler>(), Protocol.soap11);
        try {
            MessageContext mc1 = new MessageContext();
            mc1.setMEPContext(new MEPContext(mc1));
            processor1.processChain(mc1.getMEPContext(),
                                    HandlerChainProcessor.Direction.IN,
                                    HandlerChainProcessor.MEP.REQUEST,
                                    true);
            MessageContext mc2 = new MessageContext();
            mc2.setMEPContext(new MEPContext(mc2));
            processor2.processChain(mc2.getMEPContext(),
                                    HandlerChainProcessor.Direction.IN,
                                    HandlerChainProcessor.MEP.REQUEST,
                                    true);
        } catch (Exception e) {
            local_exception = e;
View Full Code Here

        // we want all good responses:
        soaphandler1_MessageResultDesired = ResultDesired.TRUE;
        soaphandler1_FaultResultDesired = ResultDesired.TRUE;

        HandlerChainProcessor processor = new HandlerChainProcessor(local_list, Protocol.soap11);
        MessageContext mc1 = new MessageContext();
        mc1.setMEPContext(new MEPContext(mc1));
        processor.processChain(mc1.getMEPContext(),
                               HandlerChainProcessor.Direction.IN,
                               HandlerChainProcessor.MEP.REQUEST,
                               false);

        assertEquals("S1m:S1c:", result);
View Full Code Here

        // we want all good responses:
        soaphandler1_MessageResultDesired = ResultDesired.TRUE;
        soaphandler1_FaultResultDesired = ResultDesired.TRUE;

        HandlerChainProcessor processor = new HandlerChainProcessor(local_list, Protocol.soap11);
        MessageContext mc1 = new MessageContext();
        mc1.setMEPContext(new MEPContext(mc1));
        processor.processChain(mc1.getMEPContext(),
                               HandlerChainProcessor.Direction.IN,
                               HandlerChainProcessor.MEP.REQUEST,
                               false);

        assertEquals("S1m:S1c:", result);
View Full Code Here

    public void onComplete(AsyncResult result) {
        if (debug) {
            log.debug("JAX-WS received the async response");
        }

        MessageContext response = null;
        try {
            response = AsyncUtils.createJAXWSMessageContext(result);
            response.setInvocationContext(invocationCtx);
            // make sure request and response contexts share a single parent
            response.setMEPContext(invocationCtx.getRequestMessageContext().getMEPContext());
        } catch (WebServiceException e) {
            cft.setError(e);
            if (debug) {
                log.debug(
                        "An error occured while processing the async response.  " + e.getMessage());
View Full Code Here

TOP

Related Classes of org.apache.axis2.jaxws.core.MessageContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.