Search in sources :

Example 56 with HTTPConduit

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

the class Helper method testGZIPServerSideOnlyInterceptorOnClient.

public boolean testGZIPServerSideOnlyInterceptorOnClient() throws Exception {
    Bus bus = BusFactory.newInstance().createBus();
    try {
        BusFactory.setThreadDefaultBus(bus);
        HelloWorld port = getPort();
        Client client = ClientProxy.getClient(port);
        HTTPConduit conduit = (HTTPConduit) client.getConduit();
        HTTPClientPolicy policy = conduit.getClient();
        // enable Accept gzip, otherwise the server will not try to reply using gzip
        policy.setAcceptEncoding("gzip;q=1.0, identity; q=0.5, *;q=0");
        // add interceptor for decoding gzip message
        ClientConfigurer configurer = ClientConfigUtil.resolveClientConfigurer();
        configurer.setConfigProperties(port, "jaxws-client-config.xml", "Interceptor Client Config");
        return ("foo".equals(port.echo("foo")));
    } finally {
        bus.shutdown(true);
    }
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) Bus(org.apache.cxf.Bus) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) ClientConfigurer(org.jboss.ws.api.configuration.ClientConfigurer) Client(org.apache.cxf.endpoint.Client)

Example 57 with HTTPConduit

use of org.apache.cxf.transport.http.HTTPConduit 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)

Example 58 with HTTPConduit

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

the class AddressingTestCase method testDecoupledEndpointForLongLastingProcessingOfInvocations.

/**
 * This shows the usage of decoupled-endpoint for getting back response on a new http connection.
 * The CXF client basically creates a destination listening at the provided decoupled endpoint address, using the
 * configured http transport factory. The client gets back a HTTP 202 accept response message immediately after
 * the call to the server, then once the actual response comes back to the decoupled endpoint, the client is
 * notified and returns control to the application code.
 *
 * @throws Exception
 */
@Test
@RunAsClient
public void testDecoupledEndpointForLongLastingProcessingOfInvocations() throws Exception {
    final Bus bus = BusFactory.newInstance().createBus();
    BusFactory.setThreadDefaultBus(bus);
    try {
        // construct proxy
        QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsaddressing", "AddressingService");
        URL wsdlURL = new URL(baseURL + "/jaxws-samples-wsa/AddressingService?wsdl");
        Service service = Service.create(wsdlURL, serviceName, new UseThreadBusFeature());
        ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class);
        Client client = ClientProxy.getClient(proxy);
        HTTPConduit conduit = (HTTPConduit) client.getConduit();
        HTTPClientPolicy policy = conduit.getClient();
        // set low connection and receive timeouts to ensure the http client can't keep the connection open till the response is received
        // 5 secs
        policy.setConnectionTimeout(5000);
        // 10 secs
        policy.setReceiveTimeout(10000);
        try {
            // this takes at least 30 secs
            proxy.sayHello("Sleepy");
            fail("Timeout exception expected");
        } catch (WebServiceException e) {
            assertTrue(e.getCause() instanceof SocketTimeoutException);
        }
        policy.setDecoupledEndpoint("http://" + getServerHost() + ":18181/jaxws-samples-wsa/decoupled-endpoint");
        // this takes at least 30 secs... but now the client doesn't time out
        String response = proxy.sayHello("Sleepy");
        assertEquals("Hello Sleepy!", response);
    } finally {
        bus.shutdown(true);
    }
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) Bus(org.apache.cxf.Bus) SocketTimeoutException(java.net.SocketTimeoutException) WebServiceException(javax.xml.ws.WebServiceException) UseThreadBusFeature(org.jboss.wsf.stack.cxf.client.UseThreadBusFeature) QName(javax.xml.namespace.QName) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) Service(javax.xml.ws.Service) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Client(org.apache.cxf.endpoint.Client) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Example 59 with HTTPConduit

use of org.apache.cxf.transport.http.HTTPConduit in project fabric8 by fabric8io.

the class WebClients method disableSslChecks.

public static void disableSslChecks(WebClient webClient) {
    HTTPConduit conduit = WebClient.getConfig(webClient).getHttpConduit();
    TLSClientParameters params = conduit.getTlsClientParameters();
    if (params == null) {
        params = new TLSClientParameters();
        conduit.setTlsClientParameters(params);
    }
    params.setTrustManagers(new TrustManager[] { new TrustEverythingSSLTrustManager() });
    params.setDisableCNCheck(true);
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) TLSClientParameters(org.apache.cxf.configuration.jsse.TLSClientParameters) TrustEverythingSSLTrustManager(io.fabric8.utils.ssl.TrustEverythingSSLTrustManager)

Example 60 with HTTPConduit

use of org.apache.cxf.transport.http.HTTPConduit in project fabric8 by fabric8io.

the class WebClients method configureUserAndPassword.

public static void configureUserAndPassword(WebClient webClient, String username, String password) {
    if (Strings.isNotBlank(username) && Strings.isNotBlank(password)) {
        HTTPConduit conduit = WebClient.getConfig(webClient).getHttpConduit();
        conduit.getAuthorization().setUserName(username);
        conduit.getAuthorization().setPassword(password);
    }
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit)

Aggregations

HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)125 Client (org.apache.cxf.endpoint.Client)52 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)47 Test (org.junit.Test)42 URL (java.net.URL)35 Bus (org.apache.cxf.Bus)32 TLSClientParameters (org.apache.cxf.configuration.jsse.TLSClientParameters)32 QName (javax.xml.namespace.QName)22 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)20 Service (javax.xml.ws.Service)16 KeyStore (java.security.KeyStore)15 AuthorizationPolicy (org.apache.cxf.configuration.security.AuthorizationPolicy)15 Greeter (org.apache.hello_world.Greeter)14 SOAPService (org.apache.hello_world.services.SOAPService)14 TrustManager (javax.net.ssl.TrustManager)13 IOException (java.io.IOException)12 TrustManagerFactory (javax.net.ssl.TrustManagerFactory)11 InputStream (java.io.InputStream)8 X509TrustManager (javax.net.ssl.X509TrustManager)8 BindingProvider (javax.xml.ws.BindingProvider)8