Example usage for org.apache.http.client HttpRequestRetryHandler HttpRequestRetryHandler

List of usage examples for org.apache.http.client HttpRequestRetryHandler HttpRequestRetryHandler

Introduction

In this page you can find the example usage for org.apache.http.client HttpRequestRetryHandler HttpRequestRetryHandler.

Prototype

HttpRequestRetryHandler

Source Link

Usage

From source file:org.mobicents.xcap.client.impl.XcapClientImpl.java

/**
 * /*from  w  ww.j  ava  2 s .co m*/
 */
public XcapClientImpl() {
    HttpParams params = new SyncBasicHttpParams();
    params.setParameter(HttpProtocolParams.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
    //params.setBooleanParameter(HttpProtocolParams.USE_EXPECT_CONTINUE,
    //        false);
    //params.setBooleanParameter(HttpConnectionParams.STALE_CONNECTION_CHECK,
    //        false);
    //params.setIntParameter(HttpConnectionParams.SOCKET_BUFFER_SIZE,
    //        8 * 1024);
    //params.setIntParameter(HttpConnectionParams.SO_TIMEOUT,
    //        15000);
    params.setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, "UTF-8");
    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
    schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));
    this.client = new DefaultHttpClient(new ThreadSafeClientConnManager(schemeRegistry), params);
    this.client.setHttpRequestRetryHandler(new HttpRequestRetryHandler() {

        public boolean retryRequest(final IOException exception, int executionCount,
                final HttpContext context) {
            return false;
        }

    });
    client.setCredentialsProvider(credentialsProvider);
}

From source file:at.ac.uniklu.mobile.sportal.api.UnikluApiClient.java

private void init() {
    // init http client
    int timeout = 20000;
    HttpParams httpParams = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(httpParams, timeout);
    HttpConnectionParams.setSoTimeout(httpParams, timeout);
    mHttpClient = new DefaultHttpClient(httpParams);
    mHttpClient.setHttpRequestRetryHandler(new HttpRequestRetryHandler() {
        @Override/*w  ww .ja  va2s. c  o  m*/
        public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
            logDebug("request retry " + executionCount + ": " + exception.getClass().getName());
            if (executionCount < 3) {
                if (exception instanceof SSLException) {
                    return true;
                }
                if (exception instanceof SocketTimeoutException) {
                    return true;
                }
                if (exception instanceof ConnectTimeoutException) {
                    return true;
                }
            }
            return false;
        }
    });

    // init gson & configure it to match server's output format
    mGson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
            .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
            .registerTypeAdapter(Notification.Type.class, new GsonNotificationTypeDeserializer()).create();
}

From source file:com.adavr.http.Client.java

public Client() {
    httpClient = new DefaultHttpClient(new BasicClientConnectionManager());
    localContext = new BasicHttpContext();
    byteStream = new ByteArrayOutputStream();

    CookieStore cookieStore = new BasicCookieStore();
    localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    httpClient.addRequestInterceptor(new HttpRequestInterceptor() {

        @Override//from  w ww. j  av  a  2s. c o  m
        public void process(final HttpRequest request, final HttpContext context)
                throws HttpException, IOException {
            if (!request.containsHeader("Accept-Encoding")) {
                request.addHeader("Accept-Encoding", "gzip");
            }
        }
    });

    httpClient.addResponseInterceptor(new HttpResponseInterceptor() {

        @Override
        public void process(final HttpResponse response, final HttpContext context)
                throws HttpException, IOException {
            HttpEntity entity = response.getEntity();
            Header ceheader = entity.getContentEncoding();
            if (ceheader != null) {
                HeaderElement[] codecs = ceheader.getElements();
                for (HeaderElement codec : codecs) {
                    if (codec.getName().equalsIgnoreCase("gzip")) {
                        response.setEntity(new GzipDecompressingEntity(response.getEntity()));
                        return;
                    }
                }
            }
        }
    });

    httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, DEFAULT_TIMEOUT);
    httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, DEFAULT_USER_AGENT);
    HttpRequestRetryHandler myRetryHandler = new HttpRequestRetryHandler() {

        @Override
        public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
            if (executionCount >= DEFAULT_RETRY) {
                // Do not retry if over max retry count
                return false;
            }
            System.out.println(exception.getClass().getName());
            if (exception instanceof NoHttpResponseException) {
                // Retry if the server dropped connection on us
                return true;
            }
            if (exception instanceof SSLHandshakeException) {
                // Do not retry on SSL handshake exception
                return false;
            }
            HttpRequest request = (HttpRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
            boolean idempotent = !(request instanceof HttpEntityEnclosingRequest);
            if (idempotent) {
                // Retry if the request is considered idempotent
                return true;
            }
            return false;
        }
    };

    httpClient.setHttpRequestRetryHandler(myRetryHandler);
}

From source file:eu.europeanaconnect.erds.HTTPResolverMultiThreaded.java

/**
 * TODO: ->Nuno: explain this part please
 *//*w  ww.ja  v  a  2  s. c o m*/
public HTTPResolverMultiThreaded() {
    HttpParams params = new BasicHttpParams();
    ConnManagerParams.setMaxTotalConnections(params, MAX_CONNECTIONS);
    ConnPerRouteBean connPerRoute = new ConnPerRouteBean(CONN_PER_ROUTE);
    ConnManagerParams.setMaxConnectionsPerRoute(params, connPerRoute);

    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));

    ClientConnectionManager clientConnectionManager = new ThreadSafeClientConnManager(params, schemeRegistry);

    this.httpClient = new DefaultHttpClient(clientConnectionManager, params);
    HttpConnectionParams.setConnectionTimeout(this.httpClient.getParams(), CONECTION_TIMEOUT);
    HttpConnectionParams.setSoTimeout(this.httpClient.getParams(), SOCKET_TIMEOUT);
    this.httpClient.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);
    this.httpClient.getParams().setBooleanParameter(ClientPNames.REJECT_RELATIVE_REDIRECT, false);
    this.httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, this.userAgentString);

    HttpRequestRetryHandler myRetryHandler = new HttpRequestRetryHandler() {
        @Override
        public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
            if (executionCount >= MAXIMUM_REQUEST_RETRIES) {
                // Do not retry if over max retry count
                return false;
            }
            if (exception instanceof NoHttpResponseException) {
                // Retry if the server dropped connection on us
                return true;
            }
            if (exception instanceof SSLHandshakeException) {
                // Do not retry on SSL handshake exception
                return false;
            }
            HttpRequest request = (HttpRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
            boolean idempotent = !(request instanceof HttpEntityEnclosingRequest);
            if (idempotent) {
                // Retry if the request is considered idempotent 
                return true;
            }
            return false;
        }

    };
    this.httpClient.setHttpRequestRetryHandler(myRetryHandler);
}

From source file:io.soabase.client.SoaClientBundle.java

private HttpClient buildHttpClient(Configuration configuration, SoaClientConfiguration clientConfiguration,
        Environment environment, RetryComponents retryComponents) {
    if (clientConfiguration.getHttpClientConfiguration() == null) {
        return null;
    }/*w  ww.  j a va2s.  c o  m*/

    HttpRequestRetryHandler nullRetry = new HttpRequestRetryHandler() {
        @Override
        public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
            return false;
        }
    };

    HttpClientConfiguration httpClientConfiguration = clientConfiguration.getHttpClientConfiguration();
    HttpClientBuilder httpClientBuilder = new HttpClientBuilder(environment).using(httpClientConfiguration)
            .using(nullRetry); // Apache's retry mechanism does not allow changing hosts. Do retries manually
    httpClientBuilder = updateHttpClientBuilder(configuration, environment, httpClientBuilder);
    HttpClient httpClient = httpClientBuilder.build(clientName);

    HttpClient client = new WrappedHttpClient(httpClient, SoaBundle.getFeatures(environment).getDiscovery(),
            retryComponents);
    SoaBundle.getFeatures(environment).putNamed(client, HttpClient.class, clientName);
    return client;
}

From source file:com.mfizz.observer.core.ServiceObserver.java

public ServiceObserver(ServiceObserverConfiguration serviceConfig, ExecutorService executor, Class<D> dataClass,
        Class<A> aggregateClass, Class<S> summaryClass, ContentParser<D> contentParser,
        ObserverNamingStrategy ons) {//from  www  .j  av a  2  s .c o  m
    this.serviceConfig = serviceConfig;
    this.executor = executor;
    this.observers = new ConcurrentHashMap<String, Observer<D>>();
    this.dataClass = dataClass;
    this.aggregateClass = aggregateClass;
    this.summaryClass = summaryClass;
    this.contentParser = contentParser;
    if (ons == null) {
        this.ons = ObserverNamingStrategy.DEFAULT;
    } else {
        this.ons = ons;
    }
    this.snapshotAllTimer = Metrics.newTimer(
            new MetricName("com.mfizz.observer.ServiceObservers", serviceConfig.getName(), "snapshot-all-time"),
            TimeUnit.MILLISECONDS, TimeUnit.MILLISECONDS);
    this.snapshotAllAttemptedCounter = new AtomicLong();
    this.snapshotAllCompletedCounter = new AtomicLong();
    this.lastSnapshotAllResult = new AtomicReference<SnapshotAllResult>();

    //this.lastSnapshotAllTimestamp = new AtomicLong(0);
    //this.lastSnapshotsCompletedCounter = new AtomicInteger();
    //this.lastSnapshotsFailedCounter = new AtomicInteger();

    this.groups = new TreeSet<String>();
    this.summary = new ConcurrentHashMap<String, SummaryGroup<S>>();
    this.snapshots = new ConcurrentHashMap<String, TimeSeries<ObserveAggregateSnapshot<A>>>();

    // always make sure "current" is added to set of vars to track
    // "current" always tracked for all
    this.serviceConfig.getPeriods().add(SummaryPeriod.parse("current"));

    //
    // create high performance http client that can be reused by all observers
    //
    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
    schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));

    PoolingClientConnectionManager cm = new PoolingClientConnectionManager(schemeRegistry);
    // increase max total connection to 200
    cm.setMaxTotal(200);
    // increase default max connection per route to 20
    cm.setDefaultMaxPerRoute(20);

    this.httpclient = new DefaultHttpClient(cm);
    this.httpclient.setHttpRequestRetryHandler(new HttpRequestRetryHandler() {
        @Override
        public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
            // always return false -- we never want a request retried
            return false;
        }
    });
    this.httpclient.getParams()
            .setIntParameter(CoreConnectionPNames.SO_TIMEOUT,
                    new Integer((int) serviceConfig.getSocketTimeout()))
            .setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,
                    new Integer((int) serviceConfig.getConnectionTimeout()))
            .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
            .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
            .setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false)
            .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false);
}

From source file:com.senseidb.svc.impl.HttpRestSenseiServiceImpl.java

private DefaultHttpClient createHttpClient(HttpRequestRetryHandler retryHandler) {
    HttpParams params = new BasicHttpParams();
    SchemeRegistry registry = new SchemeRegistry();
    registry.register(new Scheme(_scheme, _port, PlainSocketFactory.getSocketFactory()));
    ClientConnectionManager cm = new ThreadSafeClientConnManager(registry);
    DefaultHttpClient client = new DefaultHttpClient(cm, params);
    if (retryHandler == null) {
        retryHandler = new HttpRequestRetryHandler() {
            public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
                if (executionCount >= _maxRetries) {
                    // Do not retry if over max retry count
                    return false;
                }//from  www  . j a va 2s  .  c o  m
                if (exception instanceof NoHttpResponseException) {
                    // Retry if the server dropped connection on us
                    return true;
                }
                if (exception instanceof SSLHandshakeException) {
                    // Do not retry on SSL handshake exception
                    return false;
                }
                HttpRequest request = (HttpRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
                boolean idempotent = !(request instanceof HttpEntityEnclosingRequest);
                if (idempotent) {
                    // Retry if the request is considered idempotent
                    return true;
                }
                return false;
            }
        };
    }
    client.setHttpRequestRetryHandler(retryHandler);

    client.addRequestInterceptor(new HttpRequestInterceptor() {
        public void process(final HttpRequest request, final HttpContext context)
                throws HttpException, IOException {
            if (!request.containsHeader("Accept-Encoding")) {
                request.addHeader("Accept-Encoding", "gzip");
            }
        }
    });

    client.addResponseInterceptor(new HttpResponseInterceptor() {
        public void process(final HttpResponse response, final HttpContext context)
                throws HttpException, IOException {
            HttpEntity entity = response.getEntity();
            Header ceheader = entity.getContentEncoding();
            if (ceheader != null) {
                HeaderElement[] codecs = ceheader.getElements();
                for (int i = 0; i < codecs.length; i++) {
                    if (codecs[i].getName().equalsIgnoreCase("gzip")) {
                        response.setEntity(new GzipDecompressingEntity(response.getEntity()));
                        return;
                    }
                }
            }
        }
    });

    client.setKeepAliveStrategy(new DefaultConnectionKeepAliveStrategy() {
        @Override
        public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
            // Honor 'keep-alive' header
            HeaderElementIterator it = new BasicHeaderElementIterator(
                    response.headerIterator(HTTP.CONN_KEEP_ALIVE));
            while (it.hasNext()) {
                HeaderElement he = it.nextElement();
                String param = he.getName();
                String value = he.getValue();
                if ((value != null) && param.equalsIgnoreCase("timeout")) {
                    try {
                        return Long.parseLong(value) * 1000;
                    } catch (NumberFormatException ignore) {
                    }
                }
            }

            long keepAlive = super.getKeepAliveDuration(response, context);
            if (keepAlive == -1) {
                keepAlive = _defaultKeepAliveDurationMS;
            }
            return keepAlive;
        }
    });

    return client;
}

From source file:net.vexelon.mobileops.GLBClient.java

/**
 * Initialize Http Client/*from ww  w.ja v a 2  s. c om*/
 */
private void initHttpClient() {

    HttpParams params = new BasicHttpParams();
    params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
    params.setParameter(CoreProtocolPNames.USER_AGENT, UserAgentHelper.getRandomUserAgent());
    //params.setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, HTTP.UTF_8);
    // Bugfix #1: The target server failed to respond
    params.setParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, Boolean.FALSE);

    DefaultHttpClient client = new DefaultHttpClient(params);

    httpCookieStore = new BasicCookieStore();
    client.setCookieStore(httpCookieStore);

    httpContext = new BasicHttpContext();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, httpCookieStore);

    // Bugfix #1: Adding retry handler to repeat failed requests
    HttpRequestRetryHandler retryHandler = new HttpRequestRetryHandler() {

        @Override
        public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {

            if (executionCount >= MAX_REQUEST_RETRIES) {
                return false;
            }

            if (exception instanceof NoHttpResponseException || exception instanceof ClientProtocolException) {
                return true;
            }

            return false;
        }
    };
    client.setHttpRequestRetryHandler(retryHandler);

    // SSL
    HostnameVerifier verifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;

    try {
        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", new PlainSocketFactory(), 80));
        registry.register(new Scheme("https", new TrustAllSocketFactory(), 443));

        SingleClientConnManager connMgr = new SingleClientConnManager(client.getParams(), registry);

        httpClient = new DefaultHttpClient(connMgr, client.getParams());
    } catch (InvalidAlgorithmParameterException e) {
        //         Log.e(Defs.LOG_TAG, "", e);

        // init without connection manager
        httpClient = new DefaultHttpClient(client.getParams());
    }

    HttpsURLConnection.setDefaultHostnameVerifier(verifier);

}

From source file:org.apache.manifoldcf.crawler.connectors.meridio.meridiowrapper.MeridioWrapper.java

/** The Meridio Wrapper constructor that calls the Meridio login method
*
*@param log                                     a handle to a Log4j logger
*@param meridioDmwsUrl          the URL to the Meridio Document Management Web Service
*@param meridioRmwsUrl          the URL to the Meridio Records Management Web Service
*@param dmwsProxyHost           the proxy for DMWS, or null if none
*@param dmwsProxyPort           the proxy port for DMWS, or -1 if default
*@param rmwsProxyHost           the proxy for RMWS, or null if none
*@param rmwsProxyPort           the proxy port for RMWS, or -1 if default
*@param userName                        the username of the user to log in as, must include the Windows, e.g. domain\\user
*@param password                        the password of the user who is logging in
*@param clientWorkstation       an identifier for the client workstation, could be the IP address, for auditing purposes
*@param protocolFactory         the protocol factory object to use for https communication
*@param engineConfigurationFile the engine configuration object to use to communicate with the web services
*
*@throws RemoteException        if an error is encountered logging into Meridio
*/// w  w w  .j a  v a 2 s  .  com
public MeridioWrapper(Logger log, URL meridioDmwsUrl, URL meridioRmwsUrl, URL meridioManifoldCFWSUrl,
        String dmwsProxyHost, String dmwsProxyPort, String rmwsProxyHost, String rmwsProxyPort,
        String mcwsProxyHost, String mcwsProxyPort, String userName, String password, String clientWorkstation,
        javax.net.ssl.SSLSocketFactory mySSLFactory, Class resourceClass, String engineConfigurationFile)
        throws RemoteException, NumberFormatException {
    // Initialize local instance variables
    oLog = log;
    this.engineConfiguration = new ResourceProvider(resourceClass, engineConfigurationFile);
    this.clientWorkstation = clientWorkstation;

    // Set up the pool.
    // We have a choice: We can either have one httpclient instance, which gets reinitialized for every service
    // it connects with (because each one has a potentially different proxy setup), OR we can have a different
    // httpclient for each service.  The latter approach is obviously the more efficient, so I've chosen to do it
    // that way.
    PoolingClientConnectionManager localConnectionManager = new PoolingClientConnectionManager();
    localConnectionManager.setMaxTotal(1);
    if (mySSLFactory != null) {
        SSLSocketFactory myFactory = new SSLSocketFactory(mySSLFactory, new BrowserCompatHostnameVerifier());
        Scheme myHttpsProtocol = new Scheme("https", 443, myFactory);
        localConnectionManager.getSchemeRegistry().register(myHttpsProtocol);
    }
    connectionManager = localConnectionManager;

    // Parse the user and password values
    int index = userName.indexOf("\\");
    String domainUser;
    String domain;
    if (index != -1) {
        domainUser = userName.substring(index + 1);
        domain = userName.substring(0, index);
        if (oLog != null && oLog.isDebugEnabled())
            oLog.debug("Meridio: User is '" + domainUser + "', domain is '" + domain + "'");
    } else {
        domain = null;
        domainUser = userName;
        if (oLog != null && oLog.isDebugEnabled())
            oLog.debug("Meridio: User is '" + domainUser + "'; there is no domain specified");
    }

    if (oLog != null && oLog.isDebugEnabled()) {
        if (password != null && password.length() > 0)
            oLog.debug("Meridio: Password exists");
        else
            oLog.debug("Meridio: Password is null");
    }

    // Initialize the three httpclient objects

    // dmws first
    BasicHttpParams dmwsParams = new BasicHttpParams();
    dmwsParams.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true);
    dmwsParams.setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false);
    dmwsParams.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 60000);
    dmwsParams.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 900000);
    dmwsParams.setBooleanParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true);
    DefaultHttpClient localDmwsHttpClient = new DefaultHttpClient(connectionManager, dmwsParams);
    // No retries
    localDmwsHttpClient.setHttpRequestRetryHandler(new HttpRequestRetryHandler() {
        public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
            return false;
        }

    });

    localDmwsHttpClient.setRedirectStrategy(new DefaultRedirectStrategy());
    if (domainUser != null) {
        localDmwsHttpClient.getCredentialsProvider().setCredentials(
                new AuthScope(meridioDmwsUrl.getHost(), meridioDmwsUrl.getPort()),
                new NTCredentials(domainUser, password, currentHost, domain));
    }
    // Initialize proxy
    if (dmwsProxyHost != null && dmwsProxyHost.length() > 0) {
        int port = (dmwsProxyPort == null || dmwsProxyPort.length() == 0) ? 8080
                : Integer.parseInt(dmwsProxyPort);
        // Configure proxy authentication
        if (domainUser != null && domainUser.length() > 0) {
            localDmwsHttpClient.getCredentialsProvider().setCredentials(new AuthScope(dmwsProxyHost, port),
                    new NTCredentials(domainUser, password, currentHost, domain));
        }

        HttpHost proxy = new HttpHost(dmwsProxyHost, port);
        localDmwsHttpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
    }
    dmwsHttpClient = localDmwsHttpClient;

    // rmws
    BasicHttpParams rmwsParams = new BasicHttpParams();
    rmwsParams.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true);
    rmwsParams.setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false);
    rmwsParams.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 60000);
    rmwsParams.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 900000);
    rmwsParams.setBooleanParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true);
    DefaultHttpClient localRmwsHttpClient = new DefaultHttpClient(connectionManager, rmwsParams);
    // No retries
    localRmwsHttpClient.setHttpRequestRetryHandler(new HttpRequestRetryHandler() {
        public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
            return false;
        }

    });

    localRmwsHttpClient.setRedirectStrategy(new DefaultRedirectStrategy());
    if (domainUser != null) {
        localRmwsHttpClient.getCredentialsProvider().setCredentials(
                new AuthScope(meridioRmwsUrl.getHost(), meridioRmwsUrl.getPort()),
                new NTCredentials(domainUser, password, currentHost, domain));
    }
    // Initialize proxy
    if (rmwsProxyHost != null && rmwsProxyHost.length() > 0) {
        int port = (rmwsProxyPort == null || rmwsProxyPort.length() == 0) ? 8080
                : Integer.parseInt(rmwsProxyPort);
        // Configure proxy authentication
        if (domainUser != null && domainUser.length() > 0) {
            localRmwsHttpClient.getCredentialsProvider().setCredentials(new AuthScope(rmwsProxyHost, port),
                    new NTCredentials(domainUser, password, currentHost, domain));
        }

        HttpHost proxy = new HttpHost(rmwsProxyHost, port);
        localRmwsHttpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
    }
    rmwsHttpClient = localRmwsHttpClient;

    // mcws
    if (meridioManifoldCFWSUrl != null) {
        BasicHttpParams mcwsParams = new BasicHttpParams();
        mcwsParams.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true);
        mcwsParams.setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false);
        mcwsParams.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 60000);
        mcwsParams.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 900000);
        mcwsParams.setBooleanParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true);
        DefaultHttpClient localMcwsHttpClient = new DefaultHttpClient(connectionManager, mcwsParams);
        // No retries
        localMcwsHttpClient.setHttpRequestRetryHandler(new HttpRequestRetryHandler() {
            public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
                return false;
            }

        });

        localMcwsHttpClient.setRedirectStrategy(new DefaultRedirectStrategy());
        if (domainUser != null) {
            localMcwsHttpClient.getCredentialsProvider().setCredentials(
                    new AuthScope(meridioManifoldCFWSUrl.getHost(), meridioManifoldCFWSUrl.getPort()),
                    new NTCredentials(domainUser, password, currentHost, domain));
        }
        // Initialize proxy
        if (mcwsProxyHost != null && mcwsProxyHost.length() > 0) {
            int port = (mcwsProxyPort == null || mcwsProxyPort.length() == 0) ? 8080
                    : Integer.parseInt(mcwsProxyPort);
            // Configure proxy authentication
            if (domainUser != null && domainUser.length() > 0) {
                localMcwsHttpClient.getCredentialsProvider().setCredentials(new AuthScope(mcwsProxyHost, port),
                        new NTCredentials(domainUser, password, currentHost, domain));
            }

            HttpHost proxy = new HttpHost(mcwsProxyHost, port);
            localMcwsHttpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
        }
        mcwsHttpClient = localMcwsHttpClient;
    } else
        mcwsHttpClient = null;

    // Set up the stub handles
    /*=================================================================
    * Get a handle to the DMWS
    *================================================================*/
    MeridioDMLocator meridioDMLocator = new MeridioDMLocator(engineConfiguration);
    MeridioDMSoapStub meridioDMWebService = new MeridioDMSoapStub(meridioDmwsUrl, meridioDMLocator);

    meridioDMWebService.setPortName(meridioDMLocator.getMeridioDMSoapWSDDServiceName());
    meridioDMWebService.setUsername(userName);
    meridioDMWebService.setPassword(password);
    meridioDMWebService._setProperty(HTTPCLIENT_PROPERTY, dmwsHttpClient);

    meridioDMWebService_ = meridioDMWebService;

    /*=================================================================
    * Get a handle to the RMWS
    *================================================================*/
    MeridioRMLocator meridioRMLocator = new MeridioRMLocator(engineConfiguration);
    MeridioRMSoapStub meridioRMWebService = new MeridioRMSoapStub(meridioRmwsUrl, meridioRMLocator);

    meridioRMWebService.setPortName(meridioRMLocator.getMeridioRMSoapWSDDServiceName());
    meridioRMWebService.setUsername(userName);
    meridioRMWebService.setPassword(password);
    meridioRMWebService._setProperty(HTTPCLIENT_PROPERTY, rmwsHttpClient);

    meridioRMWebService_ = meridioRMWebService;

    /*=================================================================
    * Get a handle to the MeridioMetaCarta Web Service
    *================================================================*/
    if (meridioManifoldCFWSUrl != null) {
        MetaCartaLocator meridioMCWS = new MetaCartaLocator(engineConfiguration);
        Service McWsService = null;
        MetaCartaSoapStub meridioMetaCartaWebService = new MetaCartaSoapStub(meridioManifoldCFWSUrl,
                McWsService);

        meridioMetaCartaWebService.setPortName(meridioMCWS.getMetaCartaSoapWSDDServiceName());
        meridioMetaCartaWebService.setUsername(userName);
        meridioMetaCartaWebService.setPassword(password);
        meridioMetaCartaWebService._setProperty(HTTPCLIENT_PROPERTY, mcwsHttpClient);

        meridioMCWS_ = meridioMetaCartaWebService;
    }

    this.loginUnified();
}