Search in sources :

Example 41 with Conduit

use of org.apache.cxf.transport.Conduit 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 42 with Conduit

use of org.apache.cxf.transport.Conduit in project tesb-rt-se by Talend.

the class JmsConfiguratorTest method createAndConfigureDispatchAddressing.

@Test
public void createAndConfigureDispatchAddressing() {
    Service service = Service.create(SERVICE_NAME);
    service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, "jms://");
    Dispatch<Source> dispatch = service.createDispatch(PORT_NAME, Source.class, Service.Mode.PAYLOAD);
    Assert.assertNotNull(dispatch);
    JmsConfigurator jmsConfigurator = JmsConfigurator.create(dispatch);
    Assert.assertNotNull(jmsConfigurator);
    Assert.assertEquals("SoapPort", jmsConfigurator.getConfigurationPrefix());
    Assert.assertEquals(SERVICE_NAME, jmsConfigurator.getServiceName());
    Dispatch<Source> dispatch2 = jmsConfigurator.configureDispatch(dispatch, "jms://");
    Assert.assertNotNull(dispatch2);
    Conduit conduit = ((DispatchImpl) dispatch2).getClient().getConduit();
    Assert.assertNotNull(conduit);
    Assert.assertTrue(conduit instanceof JMSConduit);
    JMSConduit jmsConduit = (JMSConduit) conduit;
    JMSConfiguration jmsConfiguration = jmsConduit.getJmsConfig();
    Assert.assertNotNull(jmsConfiguration);
}
Also used : JMSConfiguration(org.apache.cxf.transport.jms.JMSConfiguration) JMSConduit(org.apache.cxf.transport.jms.JMSConduit) JMSConduit(org.apache.cxf.transport.jms.JMSConduit) Conduit(org.apache.cxf.transport.Conduit) Service(javax.xml.ws.Service) Source(javax.xml.transform.Source) JmsConfigurator(org.talend.esb.mep.requestcallback.beans.JmsConfigurator) Test(org.junit.Test)

Example 43 with Conduit

use of org.apache.cxf.transport.Conduit in project tesb-rt-se by Talend.

the class JmsConfiguratorTest method createAndConfigureDispatch.

@Test
public void createAndConfigureDispatch() {
    Service service = Service.create(SERVICE_NAME);
    service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, "jms://");
    Dispatch<Source> dispatch = service.createDispatch(PORT_NAME, Source.class, Service.Mode.PAYLOAD);
    Assert.assertNotNull(dispatch);
    JmsConfigurator jmsConfigurator = JmsConfigurator.create(dispatch);
    Assert.assertNotNull(jmsConfigurator);
    Assert.assertEquals("SoapPort", jmsConfigurator.getConfigurationPrefix());
    Assert.assertEquals(SERVICE_NAME, jmsConfigurator.getServiceName());
    Dispatch<Source> dispatch2 = jmsConfigurator.configureDispatch(dispatch);
    Assert.assertNotNull(dispatch2);
    Conduit conduit = ((DispatchImpl) dispatch2).getClient().getConduit();
    Assert.assertNotNull(conduit);
    Assert.assertTrue(conduit instanceof JMSConduit);
    JMSConduit jmsConduit = (JMSConduit) conduit;
    JMSConfiguration jmsConfiguration = jmsConduit.getJmsConfig();
    Assert.assertNotNull(jmsConfiguration);
}
Also used : JMSConfiguration(org.apache.cxf.transport.jms.JMSConfiguration) JMSConduit(org.apache.cxf.transport.jms.JMSConduit) JMSConduit(org.apache.cxf.transport.jms.JMSConduit) Conduit(org.apache.cxf.transport.Conduit) Service(javax.xml.ws.Service) Source(javax.xml.transform.Source) JmsConfigurator(org.talend.esb.mep.requestcallback.beans.JmsConfigurator) Test(org.junit.Test)

Example 44 with Conduit

use of org.apache.cxf.transport.Conduit in project tesb-rt-se by Talend.

the class DurableSubscriptionFeature method initialize.

@Override
public void initialize(Client client, Bus bus) {
    Conduit conduit = client.getConduit();
    if (conduit instanceof JMSConduit) {
        JMSConfiguration jmsConfig = ((JMSConduit) conduit).getJmsConfig();
        updateJMSConfig(jmsConfig);
    }
}
Also used : JMSConfiguration(org.apache.cxf.transport.jms.JMSConfiguration) JMSConduit(org.apache.cxf.transport.jms.JMSConduit) JMSConduit(org.apache.cxf.transport.jms.JMSConduit) Conduit(org.apache.cxf.transport.Conduit)

Example 45 with Conduit

use of org.apache.cxf.transport.Conduit in project jbossws-cxf by jbossws.

the class SOAPConnectionImpl method get.

@Override
public SOAPMessage get(Object addressObject) throws SOAPException {
    checkClosed();
    String address = getAddress(addressObject);
    ConduitInitiator ci = getConduitInitiator(address);
    // create a new Message and Exchange
    EndpointInfo info = new EndpointInfo();
    info.setAddress(address);
    Message outMessage = new MessageImpl();
    Exchange exch = new ExchangeImpl();
    outMessage.setExchange(exch);
    // sent GET request
    try {
        // TODO verify bus
        final Conduit c = ci.getConduit(info, BusFactory.getThreadDefaultBus(false));
        if (c instanceof HTTPConduit) {
            ((HTTPConduit) c).getClient().setAutoRedirect(true);
        }
        outMessage.put(Message.HTTP_REQUEST_METHOD, "GET");
        c.prepare(outMessage);
        c.setMessageObserver(createMessageObserver(c));
        c.close(outMessage);
    } catch (Exception ex) {
        throw MESSAGES.getRequestCouldNotBeSent(ex);
    }
    // read SOAPMessage
    return readSoapMessage(exch);
}
Also used : Exchange(org.apache.cxf.message.Exchange) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Message(org.apache.cxf.message.Message) SOAPMessage(javax.xml.soap.SOAPMessage) Conduit(org.apache.cxf.transport.Conduit) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) ConduitInitiator(org.apache.cxf.transport.ConduitInitiator) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) SOAPException(javax.xml.soap.SOAPException) IOException(java.io.IOException)

Aggregations

Conduit (org.apache.cxf.transport.Conduit)83 Test (org.junit.Test)36 Message (org.apache.cxf.message.Message)35 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)30 Exchange (org.apache.cxf.message.Exchange)28 IOException (java.io.IOException)18 MessageImpl (org.apache.cxf.message.MessageImpl)17 Endpoint (org.apache.cxf.endpoint.Endpoint)16 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)13 MessageObserver (org.apache.cxf.transport.MessageObserver)12 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)12 OutputStream (java.io.OutputStream)11 Bus (org.apache.cxf.Bus)11 Destination (org.apache.cxf.transport.Destination)11 ConduitInitiator (org.apache.cxf.transport.ConduitInitiator)10 InputStream (java.io.InputStream)9 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)9 ConduitInitiatorManager (org.apache.cxf.transport.ConduitInitiatorManager)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6