How do I tell wsimport to use a proxy exception url

Neil Kennedy picture Neil Kennedy · Apr 24, 2012 · Viewed 10.1k times · Source

I need to connect to an internal intranet web service. My company uses a proxy server to access the internet but intranet sites do not go through the proxy. I can navigate to the WSDL in IE and Firefox but I have to add the address to the proxy exception list in both browsers.

When I use wsimport I cannot get the WSDL because of the proxy server. Adding in or leaving out the -httpproxy arg gives me an error "Unable to tunnel through proxy" so I'm guessing this is not the way I need to do it.

Does anyone know a way I can tell wsimport to ignore the proxy server for this url?

Neil

Answer

Yogi picture Yogi · Jun 6, 2013

I arrived on this post looking for a way to use proxy for internal (intranet) URLs and skip proxy for external URLs (w3c.com) using the wsimport.exe (part of JDK 1.6, 1.7,etc). I see that it does not have the facility to put nonProxyHosts, so I went ahead and used Java class invocations.

Something like this

java -Dhttp.proxyHost=proxyServer -Dhttp.proxyPort=9000 -Dhttp.nonProxyHosts="localhost|*.intranet-domain.com" -classpath %JAVA_HOME%\lib\tools.jar com.sun.tools.internal.ws.WsImport -p com.ws.client.pkg http://app.intranet-domain.com/endpoint?wsdl 

For easier readability:

java
  -Dhttp.proxyHost=proxyServer
  -Dhttp.proxyPort=9000
  -Dhttp.nonProxyHosts="localhost|*.intranet-domain.com"
  -classpath %JAVA_HOME%\lib\tools.jar
  com.sun.tools.internal.ws.WsImport
  -p com.ws.client.pkg
  http://app.intranet-domain.com/endpoint?wsdl 

Keep in mind that "-Dhttp.nonProxyHosts" only works if you configure a proxy in that line before, you need ALL the parameters. So, if you just want to disable a default proxy you have to configure it here again.