我使用RestEasy ProxyFactory连接到REST服务。但是我需要通过Web代理连接。如何指定代理连接详细信息?
目前我正在使用以下方式创建实例:
MyInterface instance = org.jboss.resteasy.client.ProxyFactory.create(MyInterface.class,url);
instance.doStuff();
但是,它没有连接。
RestEasy似乎在使用Apache Commons HTTPClient,它不允许您使用标准Java系统属性指定代理。
答案 0 :(得分:3)
好的,我想我已经通过指定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);