Search in sources :

Example 76 with HTTPClientPolicy

use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project cu-kfs by CU-CommunityApps.

the class CULegacyTravelServiceImpl method configureWebServiceClient.

/**
 * @param client
 */
private void configureWebServiceClient(Client client) {
    Endpoint endpoint = client.getConduitSelector().getEndpoint();
    endpoint.getEndpointInfo().setAddress(updateTripEndpoint);
    client.getConduitSelector().setEndpoint(endpoint);
    HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
    HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
    httpClientPolicy.setConnectionTimeout(36000);
    httpClientPolicy.setAllowChunking(false);
    httpConduit.setClient(httpClientPolicy);
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) Endpoint(org.apache.cxf.endpoint.Endpoint) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy)

Example 77 with HTTPClientPolicy

use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project teiid by teiid.

the class SalesforceCXFTransport method connectRaw.

private OutputStream connectRaw(String uri, HashMap<String, String> httpHeaders, boolean enableCompression) {
    if (config.isTraceMessage()) {
        config.getTraceStream().println("WSC: Creating a new connection to " + uri + " Proxy = " + config.getProxy() + " username " + config.getProxyUsername());
    }
    if (this.config.getCxfConfigFile() == null) {
        this.client = WebClient.create(uri);
    } else {
        this.client = WebClient.create(uri, this.config.getCxfConfigFile());
    }
    this.client.header("User-Agent", VersionInfo.info());
    /*
         * Add all the client specific headers here
         */
    if (config.getHeaders() != null) {
        for (Entry<String, String> ent : config.getHeaders().entrySet()) {
            this.client.header(ent.getKey(), ent.getValue());
        }
    }
    if (enableCompression && config.isCompression()) {
        this.client.header("Content-Encoding", "gzip");
        this.client.header("Accept-Encoding", "gzip");
    }
    if (config.getProxyUsername() != null) {
        String token = config.getProxyUsername() + ":" + config.getProxyPassword();
        String auth = "Basic " + new String(Base64.encode(token.getBytes()));
        this.client.header("Proxy-Authorization", auth);
        this.client.header("Https-Proxy-Authorization", auth);
    }
    if (httpHeaders != null) {
        for (Map.Entry<String, String> entry : httpHeaders.entrySet()) {
            this.client.header(entry.getKey(), entry.getValue());
        }
    }
    HTTPClientPolicy clientPolicy = WebClient.getConfig(this.client).getHttpConduit().getClient();
    if (config.getReadTimeout() != 0) {
        clientPolicy.setReceiveTimeout(config.getReadTimeout());
    }
    if (config.getConnectionTimeout() != 0) {
        clientPolicy.setConnectionTimeout(config.getConnectionTimeout());
    }
    if (config.useChunkedPost()) {
        clientPolicy.setAllowChunking(true);
        clientPolicy.setChunkLength(4096);
    }
    if (config.getProxy() != Proxy.NO_PROXY) {
        InetSocketAddress addr = (InetSocketAddress) config.getProxy().address();
        clientPolicy.setProxyServer(addr.getHostName());
        clientPolicy.setProxyServerPort(addr.getPort());
    }
    return this.payload;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) HashMap(java.util.HashMap) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) Map(java.util.Map)

Example 78 with HTTPClientPolicy

use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project components by Talend.

the class NetSuiteClientService method setHttpClientPolicy.

/**
 * Set HTTP client policy for given port.
 *
 * @param port port
 */
protected void setHttpClientPolicy(PortT port) {
    HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
    httpClientPolicy.setConnectionTimeout(connectionTimeout);
    httpClientPolicy.setReceiveTimeout(receiveTimeout);
    setHttpClientPolicy(port, httpClientPolicy);
}
Also used : HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy)

Aggregations

HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)78 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)53 Client (org.apache.cxf.endpoint.Client)31 Test (org.junit.Test)27 URL (java.net.URL)12 Bus (org.apache.cxf.Bus)10 IOException (java.io.IOException)8 AuthorizationPolicy (org.apache.cxf.configuration.security.AuthorizationPolicy)8 WebClient (org.apache.cxf.jaxrs.client.WebClient)7 ClientPolicyCalculator (org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator)7 QName (javax.xml.namespace.QName)6 ProxyAuthorizationPolicy (org.apache.cxf.configuration.security.ProxyAuthorizationPolicy)6 ClientConfiguration (org.apache.cxf.jaxrs.client.ClientConfiguration)6 TLSClientParameters (org.apache.cxf.configuration.jsse.TLSClientParameters)5 Greeter (org.apache.hello_world.Greeter)5 SOAPService (org.apache.hello_world.services.SOAPService)5 Map (java.util.Map)4 BindingProvider (javax.xml.ws.BindingProvider)4 Endpoint (org.apache.cxf.endpoint.Endpoint)4 HashMap (java.util.HashMap)3