How to specify a web proxy when using a RestEasy proxy server?

I am using RestEasy ProxyFactory to connect to the REST service. However, I need to connect through a web proxy. How to specify proxy data?

I am currently creating an instance using:

MyInterface instance = org.jboss.resteasy.client.ProxyFactory.create(MyInterface.class,url); instance.doStuff(); 

However, it does not connect.

RestEasy seems to use HTTPClient Apache Commons under covers, which does not allow you to specify a proxy server using standard Java system properties.

+4
java resteasy
source share
1 answer

Ok, I think I found it by specifying ClientExecutor:

 org.apache.commons.httpclient.HttpClient httpClient = new HttpClient(); httpClient.getHostConfiguration().setProxy(proxyHost,proxyPort); ClientExecutor executor = new ApacheHttpClientExecutor(httpClient); MyInterface instance = org.jboss.resteasy.client.ProxyFactory.create(MyInterface.class,url,executor); 
+3
source share

All Articles