Search in sources :

Example 16 with Exchange

use of org.apache.cxf.message.Exchange in project cxf by apache.

the class AbstractJMSTester method createMessageObserver.

protected MessageObserver createMessageObserver() {
    return new MessageObserver() {

        public void onMessage(Message m) {
            Exchange exchange = new ExchangeImpl();
            exchange.setInMessage(m);
            m.setExchange(exchange);
            destMessage = m;
        }
    };
}
Also used : Exchange(org.apache.cxf.message.Exchange) MessageObserver(org.apache.cxf.transport.MessageObserver) Message(org.apache.cxf.message.Message) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 17 with Exchange

use of org.apache.cxf.message.Exchange in project cxf by apache.

the class STSTokenRetrieverTest method prepareMessage.

private MessageImpl prepareMessage(Bus bus, STSClient stsClient, String serviceAddress) throws EndpointException {
    MessageImpl message = new MessageImpl();
    message.put(SecurityConstants.STS_CLIENT, stsClient);
    message.put(Message.ENDPOINT_ADDRESS, serviceAddress);
    Exchange exchange = new ExchangeImpl();
    ServiceInfo si = new ServiceInfo();
    Service s = new ServiceImpl(si);
    EndpointInfo ei = new EndpointInfo();
    Endpoint ep = new EndpointImpl(bus, s, ei);
    ei.setBinding(new BindingInfo(si, null));
    message.setExchange(exchange);
    exchange.put(Endpoint.class, ep);
    return message;
}
Also used : Exchange(org.apache.cxf.message.Exchange) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) ServiceImpl(org.apache.cxf.service.ServiceImpl) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) BindingInfo(org.apache.cxf.service.model.BindingInfo) Service(org.apache.cxf.service.Service) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 18 with Exchange

use of org.apache.cxf.message.Exchange in project fabric8 by jboss-fuse.

the class LoadBalanceTargetSelector method getNextConduit.

protected Conduit getNextConduit(Message message) {
    Conduit answer = null;
    Exchange exchange = message.getExchange();
    EndpointInfo ei = endpoint.getEndpointInfo();
    String address = loadBalanceStrategy.getNextAlternateAddress();
    if (overrideAddress(message)) {
        // We need to override the Endpoint Address here
        message.put(Message.ENDPOINT_ADDRESS, address);
    }
    try {
        ConduitInitiatorManager conduitInitiatorMgr = exchange.getBus().getExtension(ConduitInitiatorManager.class);
        if (conduitInitiatorMgr != null) {
            ConduitInitiator conduitInitiator = conduitInitiatorMgr.getConduitInitiatorForUri(address);
            if (conduitInitiator != null) {
                EndpointReferenceType epr = new EndpointReferenceType();
                AttributedURIType ad = new AttributedURIType();
                ad.setValue(address);
                epr.setAddress(ad);
                answer = conduitInitiator.getConduit(ei, epr, exchange.getBus());
                MessageObserver observer = exchange.get(MessageObserver.class);
                if (observer != null) {
                    answer.setMessageObserver(observer);
                } else {
                    getLogger().warning("MessageObserver not found");
                }
            } else {
                getLogger().warning("ConduitInitiator not found: " + ei.getAddress());
            }
        } else {
            getLogger().warning("ConduitInitiatorManager not found");
        }
    } catch (IOException ex) {
        throw new Fault(ex);
    }
    return answer;
}
Also used : Exchange(org.apache.cxf.message.Exchange) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) MessageObserver(org.apache.cxf.transport.MessageObserver) Conduit(org.apache.cxf.transport.Conduit) ConduitInitiatorManager(org.apache.cxf.transport.ConduitInitiatorManager) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) ConduitInitiator(org.apache.cxf.transport.ConduitInitiator) Fault(org.apache.cxf.interceptor.Fault) IOException(java.io.IOException)

Example 19 with Exchange

use of org.apache.cxf.message.Exchange in project tesb-rt-se by Talend.

the class FlowIdProducerIn method handleMessage.

/* (non-Javadoc)
     * @see org.apache.cxf.interceptor.Interceptor#handleMessage(org.apache.cxf.message.Message)
     */
public void handleMessage(T message) throws Fault {
    String flowId = FlowIdHelper.getFlowId(message);
    if (flowId == null) {
        flowId = FlowIdProtocolHeaderCodec.readFlowId(message);
    }
    if (flowId == null) {
        flowId = FlowIdSoapCodec.readFlowId(message);
    }
    if (flowId == null) {
        Exchange ex = message.getExchange();
        if (null != ex) {
            Message reqMsg = ex.getOutMessage();
            if (null != reqMsg) {
                flowId = FlowIdHelper.getFlowId(reqMsg);
                if (null != flowId) {
                    LOG.fine("Using FlowId '" + flowId + "' from exchange.");
                }
            }
        }
    }
    if (flowId != null) {
        LOG.fine("FlowId '" + flowId + "' found in incoming message.");
    } else {
        flowId = ContextUtils.generateUUID();
        LOG.fine("No flowId found in incoming message! Generate new flowId " + flowId);
    }
    FlowIdHelper.setFlowId(message, flowId);
}
Also used : Exchange(org.apache.cxf.message.Exchange) Message(org.apache.cxf.message.Message)

Example 20 with Exchange

use of org.apache.cxf.message.Exchange in project tesb-rt-se by Talend.

the class FlowIdProducerOut method handleResponseOut.

/**
 * Handling out responce.
 *
 * @param message
 *            the message
 * @throws Fault
 *             the fault
 */
protected void handleResponseOut(T message) throws Fault {
    Message reqMsg = message.getExchange().getInMessage();
    if (reqMsg == null) {
        LOG.warning("InMessage is null!");
        return;
    }
    // No flowId for oneway message
    Exchange ex = reqMsg.getExchange();
    if (ex.isOneWay()) {
        return;
    }
    String reqFid = FlowIdHelper.getFlowId(reqMsg);
    // if some interceptor throws fault before FlowIdProducerIn fired
    if (reqFid == null) {
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("Some interceptor throws fault.Setting FlowId in response.");
        }
        reqFid = FlowIdProtocolHeaderCodec.readFlowId(message);
    }
    // write IN message to SAM repo in case fault
    if (reqFid == null) {
        Message inMsg = ex.getInMessage();
        reqFid = FlowIdProtocolHeaderCodec.readFlowId(inMsg);
        if (null != reqFid) {
            if (LOG.isLoggable(Level.FINE)) {
                LOG.fine("FlowId '" + reqFid + "' found in message of fault incoming exchange.");
                LOG.fine("Calling EventProducerInterceptor to log IN message");
            }
            handleINEvent(ex, reqFid);
        }
    }
    if (reqFid == null) {
        reqFid = FlowIdSoapCodec.readFlowId(message);
    }
    if (reqFid != null) {
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("FlowId '" + reqFid + "' found in incoming message.");
        }
    } else {
        reqFid = ContextUtils.generateUUID();
        // write IN message to SAM repo in case fault
        if (null != ex.getOutFaultMessage()) {
            if (LOG.isLoggable(Level.FINE)) {
                LOG.fine("FlowId '" + reqFid + "' generated for fault message.");
                LOG.fine("Calling EventProducerInterceptor to log IN message");
            }
            handleINEvent(ex, reqFid);
        }
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("No flowId found in incoming message! Generate new flowId " + reqFid);
        }
    }
    FlowIdHelper.setFlowId(message, reqFid);
}
Also used : Exchange(org.apache.cxf.message.Exchange) Message(org.apache.cxf.message.Message)

Aggregations

Exchange (org.apache.cxf.message.Exchange)338 Message (org.apache.cxf.message.Message)196 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)159 MessageImpl (org.apache.cxf.message.MessageImpl)144 Test (org.junit.Test)119 Endpoint (org.apache.cxf.endpoint.Endpoint)75 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)62 QName (javax.xml.namespace.QName)51 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)43 Bus (org.apache.cxf.Bus)33 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)32 Conduit (org.apache.cxf.transport.Conduit)31 Fault (org.apache.cxf.interceptor.Fault)30 IOException (java.io.IOException)28 ArrayList (java.util.ArrayList)28 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)28 MessageContentsList (org.apache.cxf.message.MessageContentsList)23 Service (org.apache.cxf.service.Service)22 SOAPMessage (javax.xml.soap.SOAPMessage)21 List (java.util.List)19