Search in sources :

Example 26 with Conduit

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

the class UndertowHTTPDestinationTest method testGetBackChannelSendFault.

@Test
public void testGetBackChannelSendFault() throws Exception {
    destination = setUpDestination(false, false);
    setUpDoService(false, true, 500);
    destination.doService(request, response);
    setUpInMessage();
    Conduit backChannel = destination.getBackChannel(inMessage);
    outMessage = setUpOutMessage();
    backChannel.prepare(outMessage);
    verifyBackChannelSend(backChannel, outMessage, 500);
}
Also used : Conduit(org.apache.cxf.transport.Conduit) Test(org.junit.Test)

Example 27 with Conduit

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

the class CorbaBindingFactoryTest method testGetCorbaConduit.

@Test
public void testGetCorbaConduit() throws Exception {
    setupServiceInfo("http://cxf.apache.org/bindings/corba/simple", "/wsdl_corbabinding/simpleIdl.wsdl", "SimpleCORBAService", "SimpleCORBAPort");
    Conduit conduit = factory.getConduit(endpointInfo, bus);
    assertNotNull(conduit);
    conduit = factory.getConduit(endpointInfo, null, bus);
    assertNotNull(conduit);
    target = EasyMock.createMock(EndpointReferenceType.class);
    conduit = factory.getConduit(endpointInfo, target, bus);
    assertNotNull(conduit);
}
Also used : EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Conduit(org.apache.cxf.transport.Conduit) Test(org.junit.Test)

Example 28 with Conduit

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

the class JavascriptGetInterceptor method handleMessage.

public void handleMessage(Message message) throws Fault {
    String method = (String) message.get(Message.HTTP_REQUEST_METHOD);
    String query = (String) message.get(Message.QUERY_STRING);
    if (!"GET".equals(method) || StringUtils.isEmpty(query)) {
        return;
    }
    String baseUri = (String) message.get(Message.REQUEST_URL);
    URI uri = null;
    try {
        uri = URI.create(baseUri);
    } catch (IllegalArgumentException iae) {
        // invalid URI, ignore and continue
        return;
    }
    Map<String, String> map = UrlUtils.parseQueryString(query);
    if (isRecognizedQuery(map, uri, message.getExchange().getEndpoint().getEndpointInfo())) {
        try {
            Conduit c = message.getExchange().getDestination().getBackChannel(message);
            Message mout = new MessageImpl();
            mout.setExchange(message.getExchange());
            message.getExchange().setOutMessage(mout);
            mout.put(Message.CONTENT_TYPE, "application/javascript;charset=UTF-8");
            c.prepare(mout);
            OutputStream os = mout.getContent(OutputStream.class);
            writeResponse(uri, map, os, message.getExchange().getEndpoint());
        } catch (IOException ioe) {
            throw new Fault(ioe);
        }
    }
}
Also used : Message(org.apache.cxf.message.Message) Conduit(org.apache.cxf.transport.Conduit) OutputStream(java.io.OutputStream) Fault(org.apache.cxf.interceptor.Fault) IOException(java.io.IOException) URI(java.net.URI) MessageImpl(org.apache.cxf.message.MessageImpl)

Example 29 with Conduit

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

the class JAXRSClientFactoryBeanTest method testGetConduit.

@Test
public void testGetConduit() throws Exception {
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    bean.setAddress("http://bar");
    bean.setResourceClass(BookStore.class);
    BookStore store = bean.create(BookStore.class);
    Conduit conduit = WebClient.getConfig(store).getConduit();
    assertTrue(conduit instanceof HTTPConduit);
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) BookStore(org.apache.cxf.jaxrs.resources.BookStore) Conduit(org.apache.cxf.transport.Conduit) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) Test(org.junit.Test)

Example 30 with Conduit

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

the class AbstractSTSClient method findOperation.

protected BindingOperationInfo findOperation(String suffix) {
    BindingInfo bi = client.getEndpoint().getBinding().getBindingInfo();
    for (BindingOperationInfo boi : bi.getOperations()) {
        SoapOperationInfo soi = boi.getExtensor(SoapOperationInfo.class);
        String soapAction = soi != null ? soi.getAction() : null;
        Object o = boi.getOperationInfo().getInput().getExtensionAttribute(new QName("http://www.w3.org/2007/05/addressing/metadata", "Action"));
        if (o instanceof QName) {
            o = ((QName) o).getLocalPart();
        }
        String wsamAction = o == null ? null : o.toString();
        if ((soapAction != null && soapAction.endsWith(suffix)) || (wsamAction != null && wsamAction.endsWith(suffix))) {
            PolicyEngine pe = bus.getExtension(PolicyEngine.class);
            Conduit conduit = client.getConduit();
            EffectivePolicy effectivePolicy = pe.getEffectiveClientRequestPolicy(client.getEndpoint().getEndpointInfo(), boi, conduit, PhaseInterceptorChain.getCurrentMessage());
            setPolicyInternal(effectivePolicy.getPolicy());
            return boi;
        }
    }
    // we can at least find it by name and then set the action and such manually later.
    for (BindingOperationInfo boi : bi.getOperations()) {
        if (suffix.endsWith(boi.getName().getLocalPart())) {
            return boi;
        }
    }
    // Still didn't find anything useful
    for (BindingOperationInfo boi : bi.getOperations()) {
        if (boi.getInput().getMessageInfo().getMessagePartsNumber() > 0) {
            MessagePartInfo mpi = boi.getInput().getMessageInfo().getFirstMessagePart();
            if ("RequestSecurityToken".equals(mpi.getConcreteName().getLocalPart())) {
                return boi;
            }
        }
    }
    return null;
}
Also used : EffectivePolicy(org.apache.cxf.ws.policy.EffectivePolicy) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) QName(javax.xml.namespace.QName) Conduit(org.apache.cxf.transport.Conduit) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) PolicyEngine(org.apache.cxf.ws.policy.PolicyEngine) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo)

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