Reputation: 1140
I try to add a proxy to my Apache CXF 3 client API.
ClientBuilder.newClient().target(serverUri)
.request()
.post();
With Jersey implementation I use ClientConfig :
ClientConfig config = new ClientConfig();
config.connectorProvider(new ApacheConnectorProvider());
config.property(ClientProperties.PROXY_URI, proxyAddress);
ClientBuilder.newClient(config) ...
And i would like to do the same thing with CXF 3 without using their specific client (I use JAX-RS client implementation) and not setting the proxy on the JVM.
Any help will be apriciated ;)
EDIT :
A start of solution can be :
client.property("http.proxy.server.uri", proxyUri);
client.property("http.proxy.server.port",proxyPort);
But i didn't found properties for proxy authentification.
Upvotes: 1
Views: 4363
Reputation: 16979
You don't use JAX-RS client, it is just an interface, see JAX-RS API. The implementation is Apache CXF client, see JAX-RS 2.0 Client API:
CXF 3.0.0 implements JAX-RS 2.0 Client API. Internally it is implemented in terms of CXF specific WebClient.
You can use Apache CXF client configuration, see Apache CXF API:
Represents the configuration of the current proxy or WebClient. Given an instance with the name 'client', one can access its configuration using a WebClient.getConfig(client) call.
Example:
Client client = ClientBuilder.newClient();
HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setProxyServer("my.proxy.domain");
policy.setProxyServerPort(80);
conduit.setClient(policy);
ProxyAuthorizationPolicy policy = new ProxyAuthorizationPolicy();
policy.setAuthorizationType("Basic");
policy.setUserName(PROXY_USER);
policy.setPassword(PROXY_PWD);
conduit.setProxyAuthorization(policy);
Upvotes: 7