Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save p4535992/60d3cbe89cb38e3944c32bf1ef28b60c to your computer and use it in GitHub Desktop.

Select an option

Save p4535992/60d3cbe89cb38e3944c32bf1ef28b60c to your computer and use it in GitHub Desktop.
import org.apache.cxf.configuration.jsse.TLSClientParameters;
import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
...
WebClient client = WebClient.create(uri);
// Add proxy
HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setProxyServer("someproxy.com.sg");
policy.setProxyServerPort(3128);
conduit.setClient(policy);
// accept json response
client.accept(MediaType.APPLICATION_JSON);
// do actual calling to http://google.com
final Response response = client.get();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment