Java Code Examples for org.apache.cxf.message.Exchange#getOutFaultMessage()

The following examples show how to use org.apache.cxf.message.Exchange#getOutFaultMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MAPAggregatorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void setUpExchangeOutbound(Exchange exchange,
                                   Message message,
                                   boolean outbound,
                                   boolean fault) {
    if (fault) {
        exchange.getOutFaultMessage();
    } else {
        exchange.getOutMessage();
    }
    EasyMock.expectLastCall().andReturn(outbound ? message : null).anyTimes();
    //exchange.setOutMessage(outbound ? message : new MessageImpl());
}
 
Example 2
Source File: CodahaleMetricsContext.java    From cxf with Apache License 2.0 5 votes vote down vote up
public void stop(long timeInNS, long inSize, long outSize, Exchange ex) {
    totals.update(timeInNS, TimeUnit.NANOSECONDS);

    if (inSize != -1) {
        incomingData.mark(inSize);
    }
    if (outSize != -1) {
        outgoingData.mark(outSize);
    }
    FaultMode fm = ex.get(FaultMode.class);
    if (fm == null && ex.getOutFaultMessage() != null) {
        fm = ex.getOutFaultMessage().get(FaultMode.class);
    }
    if (fm == null && ex.getInMessage() != null) {
        fm = ex.getInMessage().get(FaultMode.class);
    }
    if (fm != null) {
        switch (fm) {
        case CHECKED_APPLICATION_FAULT:
            checkedApplicationFaults.update(timeInNS,  TimeUnit.NANOSECONDS);
            break;
        case UNCHECKED_APPLICATION_FAULT:
            uncheckedApplicationFaults.update(timeInNS,  TimeUnit.NANOSECONDS);
            break;
        case RUNTIME_FAULT:
            runtimeFaults.update(timeInNS,  TimeUnit.NANOSECONDS);
            break;
        case LOGICAL_RUNTIME_FAULT:
            logicalRuntimeFaults.update(timeInNS,  TimeUnit.NANOSECONDS);
            break;
        default:
        }
    }
    inFlight.dec();
}
 
Example 3
Source File: ColocMessageObserver.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void setOutBoundMessage(Exchange from, Exchange to) {
    if (from.getOutFaultMessage() != null) {
        to.setInFaultMessage(from.getOutFaultMessage());
    } else {
        to.setInMessage(from.getOutMessage());
    }
}
 
Example 4
Source File: MessageSenderInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static Conduit getConduit(Message message) throws IOException {
    Exchange exchange = message.getExchange();
    Conduit conduit = exchange.getConduit(message);
    if (conduit == null
        && (exchange.getOutMessage() != null
            || exchange.getOutFaultMessage() != null)) {
        conduit = OutgoingChainInterceptor.getBackChannelConduit(message);
    }
    return conduit;
}
 
Example 5
Source File: ContextUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Propagate inbound MAPs onto full reponse & fault messages.
 *
 * @param inMAPs the inbound MAPs
 * @param exchange the current Exchange
 */
public static void propogateReceivedMAPs(AddressingProperties inMAPs,
                                          Exchange exchange) {
    if (exchange.getOutMessage() == null) {
        exchange.setOutMessage(createMessage(exchange));
    }
    propogateReceivedMAPs(inMAPs, exchange.getOutMessage());
    if (exchange.getOutFaultMessage() == null) {
        exchange.setOutFaultMessage(createMessage(exchange));
    }
    propogateReceivedMAPs(inMAPs, exchange.getOutFaultMessage());
}
 
Example 6
Source File: ClientImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected Exception getException(Exchange exchange) {
    if (exchange.getInFaultMessage() != null) {
        return exchange.getInFaultMessage().getContent(Exception.class);
    } else if (exchange.getOutFaultMessage() != null) {
        return exchange.getOutFaultMessage().getContent(Exception.class);
    } else if (exchange.getInMessage() != null) {
        return exchange.getInMessage().getContent(Exception.class);
    }
    return null;
}
 
Example 7
Source File: ExchangeUtils.java    From fuchsia with Apache License 2.0 5 votes vote down vote up
public static Exception getException(Exchange exchange) {
    Exception throwable = exchange.get(Exception.class);

    if (exchange.getInFaultMessage() != null) {
        return exchange.getInFaultMessage().getContent(Exception.class);
    } else if (exchange.getOutFaultMessage() != null) {
        return exchange.getOutFaultMessage().getContent(Exception.class);
    }

    if (throwable != null) {
        return throwable;
    }

    throwable = getException(exchange.getOutMessage());

    if (throwable != null) {
        return throwable;
    }

    throwable = getException(exchange.getInMessage());

    if (throwable != null) {
        return throwable;
    }

    return null;
}
 
Example 8
Source File: AbstractJAXWSHandlerInterceptor.java    From cxf with Apache License 2.0 4 votes vote down vote up
private boolean isOutbound(T message, Exchange ex) {
    return message == ex.getOutMessage()
        || message == ex.getOutFaultMessage();
}
 
Example 9
Source File: JMSConduit.java    From cxf with Apache License 2.0 4 votes vote down vote up
/**
 * Send the JMS message and if the MEP is not oneway receive the response.
 *
 * @param exchange the Exchange containing the outgoing message
 * @param request  the payload of the outgoing JMS message
 */
public void sendExchange(final Exchange exchange, final Object request) {
    LOG.log(Level.FINE, "JMSConduit send message");

    final Message outMessage = exchange.getOutMessage() == null
        ? exchange.getOutFaultMessage()
        : exchange.getOutMessage();
    if (outMessage == null) {
        throw new RuntimeException("Exchange to be sent has no outMessage");
    }

    jmsConfig.ensureProperlyConfigured();
    assertIsNotTextMessageAndMtom(outMessage);

    try (ResourceCloser closer = new ResourceCloser()) {
        Connection c;

        if (jmsConfig.isOneSessionPerConnection()) {
            c = closer.register(JMSFactory.createConnection(jmsConfig));
            c.start();
        } else {
            c = getConnection();
        }

        Session session = closer.register(c.createSession(false, 
                                                          Session.AUTO_ACKNOWLEDGE));

        if (exchange.isOneWay()) {
            sendMessage(request, outMessage, null, null, closer, session);
        } else {
            sendAndReceiveMessage(exchange, request, outMessage, closer, session);
        }
    } catch (JMSException e) {
        if (this.jmsListener != null) {
            this.jmsListener.shutdown();
        }
        this.jmsListener = null;
        // Close connection so it will be refreshed on next try
        if (!jmsConfig.isOneSessionPerConnection()) {
            if (exchange.get(JMSUtil.JMS_MESSAGE_CONSUMER) != null) {
                ResourceCloser.close(exchange.get(JMSUtil.JMS_MESSAGE_CONSUMER));
            }
            ResourceCloser.close(connection);
            this.connection = null;
            jmsConfig.resetCachedReplyDestination();
        }
        this.staticReplyDestination = null;
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e1) {
            // Ignore
        }
        throw JMSUtil.convertJmsException(e);
    }
}