public DVWebApiClient( String serviceUrl, String sessionId, boolean useSystemProxies, int connectTimeoutInSeconds) { try { this.serviceUrl = serviceUrl; this.sessionId = sessionId; this.connectTimeoutInSeconds = connectTimeoutInSeconds; if (useSystemProxies) { // System.setProperty("java.net.useSystemProxies", "true"); } // remove the java applet/javaws CookieManager because it interferes with the JSESSIONID // cookie we try to set which came from the browser CookieManager.setDefault(null); Map<String, String> cookies = new HashMap(); // if session does not exist create it and set it if (sessionId == null || sessionId.length() == 0) { WebApi tempProxy = (WebApi) MyProxyFactory.getProxy( WebApi.class, new URL(serviceUrl), this.getClass().getClassLoader(), connectTimeoutInSeconds * 1000, true, cookies, xForwardedFor); sessionId = tempProxy.getWebSessionId(); } cookies.put("JSESSIONID", sessionId); webApiProxy = (WebApi) MyProxyFactory.getProxy( WebApi.class, new URL(serviceUrl), this.getClass().getClassLoader(), connectTimeoutInSeconds * 1000, true, cookies, xForwardedFor); } catch (Throwable ex) { throw new RuntimeException(ex); } }