Package org.apache.axis2.jaxws.core

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


        // 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) {
                cft.setError(wse);
            }

            cft.setError(e);
View Full Code Here


     * would be used in a "client outbound handler throws exception" case since that would
     * mean we never hit the InvocationController and thus never hit the Axis layer.
     */
    public static MessageContext createMinimalResponseMessageContext(MessageContext mc) {
        org.apache.axis2.context.MessageContext sourceAxisMC = mc.getAxisMessageContext();
        MessageContext newMC = new MessageContext(sourceAxisMC);
        newMC.setMEPContext(mc.getMEPContext());
        newMC.setEndpointDescription(mc.getEndpointDescription());
        newMC.setOperationDescription(mc.getOperationDescription());
        return newMC;
    }
View Full Code Here

    public static MessageContext createFaultMessageContext(MessageContext mc) {
        try {
            org.apache.axis2.context.MessageContext faultMC =
                    MessageContextBuilder.createFaultMessageContext(mc.getAxisMessageContext(),
                                                                    null);
            MessageContext jaxwsFaultMC = new MessageContext(faultMC);
            jaxwsFaultMC.setOutbound(true);
            jaxwsFaultMC.setServer(true);
            jaxwsFaultMC.setMEPContext(mc.getMEPContext());
            jaxwsFaultMC.setEndpointDescription(mc.getEndpointDescription());
            jaxwsFaultMC.setOperationDescription(mc.getOperationDescription());
            return jaxwsFaultMC;
        }
        catch (AxisFault e) {
            throw ExceptionFactory.makeWebServiceException(e);
        }
View Full Code Here

        }
        if (ic.getRequestMessageContext() == null) {
            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr2"));
        }

        MessageContext request = ic.getRequestMessageContext();
        MessageContext response = null;

        request.setProperty(Constants.INVOCATION_PATTERN, InvocationPattern.SYNC);

        // Invoke outbound handlers.
        boolean success =
                HandlerInvokerUtils.invokeOutboundHandlers(request.getMEPContext(),
                                                           ic.getHandlers(),
                                                           HandlerChainProcessor.MEP.REQUEST,
                                                           false);

        if (success) {
            // If there are any headers understood by handlers, then set a property
            // on the message context so the response mustUnderstand processing takes those
            // understood headers into consideration.
            registerUnderstoodHeaders(request, ic.getHandlers());
            prepareRequest(request);
            response = doInvoke(request);
            prepareResponse(response);
           
            // make sure request and response contexts share a single parent
            response.setMEPContext(request.getMEPContext());

            /*
             * TODO TODO TODO review
             *
             * In most cases we are adding the endpointDesc to the
             * MessageContext. Notice here that the "response" object is set by
             * the call to doInvoke. It's a new context we are now working with.
             * The invokeInboundHandlers uses that context way down in
             * createMessageContext --> ContextUtils.addProperties()
             *
             * This may also occur in the AsyncResponse class when calling
             * invokeInboundHandlers
             *
             * For now, make sure the endpointDesc is set on the response
             * context.
             */
            response.setEndpointDescription(request.getEndpointDescription());

            // Invoke inbound handlers.
            TransportHeadersAdapter.install(response);
            AttachmentsAdapter.install(response);
            SOAPHeadersAdapter.install(response);
            HandlerInvokerUtils.invokeInboundHandlers(response.getMEPContext(),
                                                      ic.getHandlers(),
                                                      HandlerChainProcessor.MEP.RESPONSE,
                                                      false);
        } else { // the outbound handler chain must have had a problem, and
                    // we've reversed directions
            response = MessageContextUtils.createMinimalResponseMessageContext(request);
            // since we've reversed directions, the message has "become a
            // make sure request and response contexts share a single parent
            response.setMEPContext(request.getMEPContext());
            response.setMessage(request.getMessage());
        }
        ic.setResponseMessageContext(response);
        return ic;
    }
View Full Code Here

        }
        if (ic.getRequestMessageContext() == null) {
            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr2"));
        }

        MessageContext request = ic.getRequestMessageContext();
        request.setProperty(Constants.INVOCATION_PATTERN, InvocationPattern.ONEWAY);

        // Invoke outbound handlers.
        boolean success =
                HandlerInvokerUtils.invokeOutboundHandlers(request.getMEPContext(),
                                                           ic.getHandlers(),
                                                           HandlerChainProcessor.MEP.REQUEST,
                                                           true);

        if (success) {
            prepareRequest(request);
            doInvokeOneWay(request);
        } else { // the outbound handler chain must have had a problem, and we've reversed directions
            // check to see if problem is due to a handler throwing an exception.  If so, throw it,
            // even in this oneWay invoke.
            Exception e = request.getCausedByException();
            if (e != null) {
                throw (Exception)e.getCause();
            }
        }
        return;
View Full Code Here

        }
        if (ic.getRequestMessageContext() == null) {
            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr2"));
        }

        MessageContext request = ic.getRequestMessageContext();
        request.setProperty(Constants.INVOCATION_PATTERN, InvocationPattern.ASYNC_POLLING);

        Response resp = null;

        // Invoke outbound handlers.
        // TODO uncomment, and get the EndpointDescription from the request context, which should soon be available
        boolean success =
                HandlerInvokerUtils.invokeOutboundHandlers(request.getMEPContext(),
                                                           ic.getHandlers(),
                                                           HandlerChainProcessor.MEP.REQUEST,
                                                           false);
        if (success) {
            // If there are any headers understood by handlers, then set a property
View Full Code Here

                throw ExceptionFactory.makeWebServiceException(Messages
                                .getMessage("ExecutorShutdown"));
            }
        }

        MessageContext request = ic.getRequestMessageContext();
        request.setProperty(Constants.INVOCATION_PATTERN, InvocationPattern.ASYNC_CALLBACK);

        Future<?> future = null;

        // Invoke outbound handlers.
        boolean success =
                HandlerInvokerUtils.invokeOutboundHandlers(request.getMEPContext(),
                                                           ic.getHandlers(),
                                                           HandlerChainProcessor.MEP.REQUEST,
                                                           false);
        if (success) {
            // If there are any headers understood by handlers, then set a property
View Full Code Here

        }

        org.apache.axis2.context.MessageContext axisRequestMsgCtx = request.getAxisMessageContext();
        org.apache.axis2.context.MessageContext axisResponseMsgCtx = null;

        MessageContext response = null;

        AxisFault faultexception =
                null// don't let the keyword "fault" confuse you.  This is an exception class.
        try {
            execute(opClient, true, axisRequestMsgCtx);
        } catch (AxisFault af) {
            // If an AxisFault was thrown, we need to cleanup the original OperationContext.
            // Failure to do so results in a memory leak.
            opClient.getOperationContext().cleanup();
            // save the fault in case it didn't come from the endpoint, and thus
            // there would be no message on the MessageContext
            faultexception = af;
            if (log.isDebugEnabled()) {
                log.debug(axisRequestMsgCtx.getLogIDString() + " AxisFault received from client: " +
                        af.getMessage());
            }
        }

        try {
            // Collect the response MessageContext and envelope
            axisResponseMsgCtx = opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
            response = new MessageContext(axisResponseMsgCtx);
            response.setMEPContext(request.getMEPContext());

            // If there was a local exception caught and either there is no response message
            // OR the response message exists but is not a fault, then set the local exception
            // on the response and determine how to set the response message to correspond to
            // the local exception
            if ((faultexception != null) && ((response.getMessage() == null)
                    || (!response.getMessage().isFault()))) {
                // Unless this behavior is disabled, convert the local exception to SOAPFaultException
                // and set it on the response message.  This will also cause the JAX-WS application handler
                // handleFault() methods to be called.
                if (!isSOAPFaultForLocalExceptionDisabled(response)) {
                    HandlerChainProcessor.convertToFaultMessage(request.getMEPContext(), faultexception,
                            request.getMessage().getProtocol());
                    response.setLocalException(faultexception);
                } else {
                    // The behavior was disabled, so instead of creating a SOAPFaultException
                    // just create an empty message and set the local exception on it.  This will cause the
                    // JAX-WS application handler handleMessage() methods to be called with the empty message.
                    MessageFactory factory =
                            (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
                    Message message = factory.create(request.getMessage().getProtocol());
                    response.setLocalException(faultexception);
                    response.setMessage(message);
                }
            }

            // This assumes that we are on the ultimate execution thread
            ThreadContextMigratorUtil.performMigrationToThread(
View Full Code Here

            return new ArrayList<Handler>();
        }

        ArrayList<Handler> handlers = new ArrayList<Handler>();
        // Create temporary MessageContext to pass information to HandlerLifecycleManager
        MessageContext ctx = new MessageContext();
        ctx.setEndpointDescription(serviceDesc.getEndpointDescription(portInfo.getPortName()));

        HandlerLifecycleManager hlm = createHandlerlifecycleManager();

        for (Iterator<Class> iterator = handlerClasses.iterator(); iterator.hasNext();) {
            Class aClass = iterator.next();
View Full Code Here

            TreeSet<String> packages = marshalDesc.getPackages();
            String packagesKey = marshalDesc.getPackagesKey();
           
            // Remember this unmarshal information so that we can speed up processing
            // the next time.
            MessageContext mc = message.getMessageContext();
            if (MethodMarshallerUtils.getUnmarshalInfoParameter(mc) == null &&
                shouldRegiserUnmarshalInfo(operationDesc, marshalDesc, endpointDesc)) {
              MethodMarshallerUtils.registerUnmarshalInfo(message.getMessageContext(),
                                                        packages,
                                                        packagesKey);
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.