How do I specify a web proxy when using RestEasy client proxy?
Asked Answered
U

1

5

I am using a RestEasy ProxyFactory to connecting to a REST service. However I need to connect via a web proxy. How do I specify the proxy connection details?

At the moment I am creating the instance using:

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

However, it does not connect.

RestEasy seems to be using Apache Commons HTTPClient under the covers, which does not allow you to specify a proxy using the standard Java System Properties.

Unvoiced answered 9/3, 2011 at 17:30 Comment(0)
U
3

Ok I think I've found it by specifying the 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);
Unvoiced answered 9/3, 2011 at 18:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.