When VM args "-Dhttp.proxyHost=xxxxxxxx -Dhttp.proxyPort=3128" are set, there is no way to connect a webservice directly without passing throuh the proxy xxxxxxxx.
The client CXF is build as following :
When creating the instance with , CXF use HttpURLConnectionFactoryImpl (or HttpsURLConnectionFactory) to open the url :
When the variable "proxy" is null, url.openConnection() is used, and benifits of VM args (http.proxyHost and http.proxyPort).
The only solution to bypass the proxy, while keeping existing VM args, is to add a System property "http.nonProxyHosts" in order to exclude the host of the proxy. This can be done with an other VM arg "-Dhttp.nonProxyHosts=xxxx" or programmatically : System.setProperty("http.nonProxyHosts", "xxxx")
According to http://download.oracle.com/javase/6/docs/technotes/guides/net/proxies.html (chapter 3 Proxy class) when no proxy is required url.openConnection() should be used like this :
The technote points out : "Now, this guarantees you that this specific URL will be retrieved though a direct connection bypassing any other proxy settings, which can be convenient."
I think that using url.openConnection(Proxy.NO_PROXY) could fix this problem in :
- org.apache.cxf.transport.http.HttpURLConnectionFactoryImpl.createConnection(Proxy proxy, URL url) > line #51 (release 2.3.1)
- org.apache.cxf.transport.https.HttpsURLConnectionFactory.createConnection(Proxy proxy, URL url) > line #120 (release 2.3.1)
WARNING : this issue can conflicts with this other one : CXF-2839
A lot of tests will be required.