I am calling a external webservice but I have to use proxy settings and
authorization. How do i do that using CXF? I am configuring that in java
using conduit but its not working. When I use the same set of credentials
using the raw HTTP client it works but not through CXF conduit. here is the
sample code I used.
this is the HTTP way which works:
CloseableHttpClient httpclient = null;
HttpHost proxyHost = null;
HttpHost targetHost = new HttpHost(<hostname>,<port>);
RequestConfig config = null;
if(wsUtil.getProxyRequired() != null)
credsProvider =
getCredentialObj(wsUtil.getProxyRequired());
proxyHost = new HttpHost(wsUtil.getProxyUrl(),
wsUtil.getProxyPort(),wsUtil.getProxyType());
config =
RequestConfig.custom().setProxy(proxyHost).build();
httpclient =
HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
this is the cxf way which doesn't work:
HTTPClientPolicy clientPolicy = conduit.getClient();
clientPolicy.setProxyServer(wsUtil.getProxyUrl());
clientPolicy.setProxyServerPort(wsUtil.getProxyPort());
clientPolicy.setProxyServerType(ProxyServerType.HTTP);
conduit.getProxyAuthorization().setUserName(wsUtil.getProxyId());
conduit.getProxyAuthorization().setPassword(wsUtil.getProxyPwd());
authorization. How do i do that using CXF? I am configuring that in java
using conduit but its not working. When I use the same set of credentials
using the raw HTTP client it works but not through CXF conduit. here is the
sample code I used.
this is the HTTP way which works:
CloseableHttpClient httpclient = null;
HttpHost proxyHost = null;
HttpHost targetHost = new HttpHost(<hostname>,<port>);
RequestConfig config = null;
if(wsUtil.getProxyRequired() != null)
credsProvider =
getCredentialObj(wsUtil.getProxyRequired());
proxyHost = new HttpHost(wsUtil.getProxyUrl(),
wsUtil.getProxyPort(),wsUtil.getProxyType());
config =
RequestConfig.custom().setProxy(proxyHost).build();
httpclient =
HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
this is the cxf way which doesn't work:
HTTPClientPolicy clientPolicy = conduit.getClient();
clientPolicy.setProxyServer(wsUtil.getProxyUrl());
clientPolicy.setProxyServerPort(wsUtil.getProxyPort());
clientPolicy.setProxyServerType(ProxyServerType.HTTP);
conduit.getProxyAuthorization().setUserName(wsUtil.getProxyId());
conduit.getProxyAuthorization().setPassword(wsUtil.getProxyPwd());