((com.sun.xml.rpc.client.StubBase)myRemoteStub)._setTransportFactory(new ClientTransportFactory() { @Override public ClientTransport create() { return new HttpClientTransport() { @Override protected HttpURLConnection createHttpConnection(String endpoint, SOAPMessageContext context) throws IOException { HttpURLConnection conn = super.createHttpConnection(endpoint, context); conn.setConnectTimeout(2000); conn.setReadTimeout(2000); return conn; } }; } });
public HttpClient getSendHttpClient() { if (sendHttpClient == null) { sendHttpClient = createHttpClient(); } return sendHttpClient; }
HttpClient httpClient = getReceiveHttpClient(); URI remoteUrl = getRemoteUrl(); while (!isStopped() && !isStopping()) { configureMethod(httpMethod); HttpResponse answer = null; Thread.sleep(1000); } catch (InterruptedException e) { onException(new InterruptedIOException()); Thread.currentThread().interrupt(); break; onException(new IOException("Failed to perform GET on: " + remoteUrl + " as response was: " + answer)); break; DataInputStream stream = createDataInputStream(answer); Object command = getTextWireFormat().unmarshal(stream); if (command == null) { LOG.debug("Received null command from url: " + remoteUrl); } else { doConsume(command); onException(IOExceptionSupport.create("Failed to perform GET on: " + remoteUrl + " Reason: " + e.getMessage(), e)); break; } finally {
@Override public void oneway(Object command) throws IOException { if (isStopped()) { throw new IOException("stopped."); HttpPost httpMethod = new HttpPost(getRemoteUrl().toString()); configureMethod(httpMethod); String data = getTextWireFormat().marshalText(command); byte[] bytes = data.getBytes("UTF-8"); if (useCompression && canSendCompressed && bytes.length > minSendAsCompressedSize) { HttpResponse answer = null; try { client = getSendHttpClient(); answer = client.execute(httpMethod); int status = answer.getStatusLine().getStatusCode(); stop(); } catch (Exception e) { LOG.warn("Error trying to stop HTTP client: "+ e, e);
protected HttpClient createHttpClient() { DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager()); if (useCompression) { client.addRequestInterceptor( new HttpRequestInterceptor() { @Override public void process(HttpRequest request, HttpContext context) { // We expect to received a compression response that we un-gzip request.addHeader("Accept-Encoding", "gzip"); } }); } if (getProxyHost() != null) { HttpHost proxy = new HttpHost(getProxyHost(), getProxyPort()); client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); if(getProxyUser() != null && getProxyPassword() != null) { client.getCredentialsProvider().setCredentials( new AuthScope(getProxyHost(), getProxyPort()), new UsernamePasswordCredentials(getProxyUser(), getProxyPassword())); } } return client; }
LOG.trace("HTTP GET consumer thread starting: " + this); HttpClient httpClient = getReceiveHttpClient(); URI remoteUrl = getRemoteUrl(); configureMethod(httpMethod);
HttpClient httpClient = getReceiveHttpClient(); URI remoteUrl = getRemoteUrl(); while (!isStopped() && !isStopping()) { configureMethod(httpMethod); HttpResponse answer = null; Thread.sleep(1000); } catch (InterruptedException e) { onException(new InterruptedIOException()); Thread.currentThread().interrupt(); break; onException(new IOException("Failed to perform GET on: " + remoteUrl + " as response was: " + answer)); break; DataInputStream stream = createDataInputStream(answer); Object command = getTextWireFormat().unmarshal(stream); if (command == null) { LOG.debug("Received null command from url: " + remoteUrl); } else { doConsume(command); onException(IOExceptionSupport.create("Failed to perform GET on: " + remoteUrl + " Reason: " + e.getMessage(), e)); break; } finally {
@Override public void oneway(Object command) throws IOException { if (isStopped()) { throw new IOException("stopped."); HttpPost httpMethod = new HttpPost(getRemoteUrl().toString()); configureMethod(httpMethod); String data = getTextWireFormat().marshalText(command); byte[] bytes = data.getBytes("UTF-8"); if (useCompression && canSendCompressed && bytes.length > minSendAsCompressedSize) { HttpResponse answer = null; try { client = getSendHttpClient(); answer = client.execute(httpMethod); int status = answer.getStatusLine().getStatusCode(); stop(); } catch (Exception e) { LOG.warn("Error trying to stop HTTP client: "+ e, e);
protected HttpClient createHttpClient() { DefaultHttpClient client = new DefaultHttpClient(createClientConnectionManager()); if (useCompression) { client.addRequestInterceptor( new HttpRequestInterceptor() { @Override public void process(HttpRequest request, HttpContext context) { // We expect to received a compression response that we un-gzip request.addHeader("Accept-Encoding", "gzip"); } }); } if (getProxyHost() != null) { HttpHost proxy = new HttpHost(getProxyHost(), getProxyPort()); client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); if (client.getConnectionManager().getSchemeRegistry().get("http") == null) { client.getConnectionManager().getSchemeRegistry().register( new Scheme("http", getProxyPort(), PlainSocketFactory.getSocketFactory())); } if(getProxyUser() != null && getProxyPassword() != null) { client.getCredentialsProvider().setCredentials( new AuthScope(getProxyHost(), getProxyPort()), new UsernamePasswordCredentials(getProxyUser(), getProxyPassword())); } } HttpParams params = client.getParams(); HttpConnectionParams.setSoTimeout(params, soTimeout); HttpClientParams.setCookiePolicy(params, CookiePolicy.BROWSER_COMPATIBILITY); return client; }
LOG.trace("HTTP GET consumer thread starting: " + this); HttpClient httpClient = getReceiveHttpClient(); URI remoteUrl = getRemoteUrl(); configureMethod(httpMethod);
HttpClient httpClient = getReceiveHttpClient(); URI remoteUrl = getRemoteUrl(); while (!isStopped() && !isStopping()) { configureMethod(httpMethod); HttpResponse answer = null; Thread.sleep(1000); } catch (InterruptedException e) { onException(new InterruptedIOException()); Thread.currentThread().interrupt(); break; onException(new IOException("Failed to perform GET on: " + remoteUrl + " as response was: " + answer)); break; DataInputStream stream = createDataInputStream(answer); Object command = getTextWireFormat().unmarshal(stream); if (command == null) { LOG.debug("Received null command from url: " + remoteUrl); } else { doConsume(command); onException(IOExceptionSupport.create("Failed to perform GET on: " + remoteUrl + " Reason: " + e.getMessage(), e)); break; } finally {
@Override public void oneway(Object command) throws IOException { if (isStopped()) { throw new IOException("stopped."); HttpPost httpMethod = new HttpPost(getRemoteUrl().toString()); configureMethod(httpMethod); String data = getTextWireFormat().marshalText(command); byte[] bytes = data.getBytes("UTF-8"); if (useCompression && canSendCompressed && bytes.length > minSendAsCompressedSize) { HttpResponse answer = null; try { client = getSendHttpClient(); answer = client.execute(httpMethod); int status = answer.getStatusLine().getStatusCode(); stop(); } catch (Exception e) { LOG.warn("Error trying to stop HTTP client: "+ e, e);
protected HttpClient createHttpClient() { DefaultHttpClient client = new DefaultHttpClient(createClientConnectionManager()); if (useCompression) { client.addRequestInterceptor( new HttpRequestInterceptor() { @Override public void process(HttpRequest request, HttpContext context) { // We expect to received a compression response that we un-gzip request.addHeader("Accept-Encoding", "gzip"); } }); } if (getProxyHost() != null) { HttpHost proxy = new HttpHost(getProxyHost(), getProxyPort()); client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); if (client.getConnectionManager().getSchemeRegistry().get("http") == null) { client.getConnectionManager().getSchemeRegistry().register( new Scheme("http", getProxyPort(), PlainSocketFactory.getSocketFactory())); } if(getProxyUser() != null && getProxyPassword() != null) { client.getCredentialsProvider().setCredentials( new AuthScope(getProxyHost(), getProxyPort()), new UsernamePasswordCredentials(getProxyUser(), getProxyPassword())); } } HttpParams params = client.getParams(); HttpConnectionParams.setSoTimeout(params, soTimeout); HttpClientParams.setCookiePolicy(params, CookiePolicy.BROWSER_COMPATIBILITY); return client; }
LOG.trace("HTTP GET consumer thread starting: " + this); HttpClient httpClient = getReceiveHttpClient(); URI remoteUrl = getRemoteUrl(); configureMethod(httpMethod);
public HttpClient getSendHttpClient() { if (sendHttpClient == null) { sendHttpClient = createHttpClient(); } return sendHttpClient; }
protected Transport createTransport(URI location, WireFormat wf) throws IOException { TextWireFormat textWireFormat = asTextWireFormat(wf); // need to remove options from uri URI uri; try { uri = URISupport.removeQuery(location); } catch (URISyntaxException e) { MalformedURLException cause = new MalformedURLException("Error removing query on " + location); cause.initCause(e); throw cause; } return new HttpClientTransport(textWireFormat, uri); }
LOG.trace("HTTP GET consumer thread starting: " + this); HttpClient httpClient = getReceiveHttpClient(); URI remoteUrl = getRemoteUrl(); while (!isStopped() && !isStopping()) { configureMethod(httpMethod); HttpResponse answer = null; Thread.sleep(1000); } catch (InterruptedException e) { onException(new InterruptedIOException()); break; onException(new IOException("Failed to perform GET on: " + remoteUrl + " as response was: " + answer)); break; DataInputStream stream = createDataInputStream(answer); Object command = (Object)getTextWireFormat().unmarshal(stream); if (command == null) { LOG.debug("Received null command from url: " + remoteUrl); } else { doConsume(command); onException(IOExceptionSupport.create("Failed to perform GET on: " + remoteUrl + " Reason: " + e.getMessage(), e)); break; } finally {
public void oneway(Object command) throws IOException { if (isStopped()) { throw new IOException("stopped."); HttpPost httpMethod = new HttpPost(getRemoteUrl().toString()); configureMethod(httpMethod); String data = getTextWireFormat().marshalText(command); byte[] bytes = data.getBytes("UTF-8"); if (useCompression && canSendCompressed && bytes.length > minSendAsCompressedSize) { HttpResponse answer = null; try { client = getSendHttpClient(); HttpParams params = client.getParams(); HttpConnectionParams.setSoTimeout(params, soTimeout); stop(); } catch (Exception e) { LOG.warn("Error trying to stop HTTP client: "+ e, e);
protected HttpClient createHttpClient() { DefaultHttpClient client = new DefaultHttpClient(createClientConnectionManager()); if (useCompression) { client.addRequestInterceptor( new HttpRequestInterceptor() { @Override public void process(HttpRequest request, HttpContext context) { // We expect to received a compression response that we un-gzip request.addHeader("Accept-Encoding", "gzip"); } }); } if (getProxyHost() != null) { HttpHost proxy = new HttpHost(getProxyHost(), getProxyPort()); client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); if (client.getConnectionManager().getSchemeRegistry().get("http") == null) { client.getConnectionManager().getSchemeRegistry().register( new Scheme("http", getProxyPort(), PlainSocketFactory.getSocketFactory())); } if(getProxyUser() != null && getProxyPassword() != null) { client.getCredentialsProvider().setCredentials( new AuthScope(getProxyHost(), getProxyPort()), new UsernamePasswordCredentials(getProxyUser(), getProxyPassword())); } } HttpParams params = client.getParams(); HttpConnectionParams.setSoTimeout(params, soTimeout); HttpClientParams.setCookiePolicy(params, CookiePolicy.BROWSER_COMPATIBILITY); return client; }
LOG.trace("HTTP GET consumer thread starting: " + this); HttpClient httpClient = getReceiveHttpClient(); URI remoteUrl = getRemoteUrl(); configureMethod(httpMethod);