How do I tell wsimport to use a proxy exception url

夙愿已清 提交于 2019-12-05 01:34:38

问题


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


回答1:


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.




回答2:


I found the answer. You need to add the following as a JVM parameter and it uses the Internet Explorer (or Safari on Mac I assume) proxy address and exclusion list.

-Djava.net.useSystemProxies=true

I got the anser from http://jeannotsweblog.blogspot.co.uk/2009/06/wsimport-with-proxy.html




回答3:


Currently wsimport is broken in this regard.

I created two tickets for that:

  1. https://java.net/jira/browse/JAX_WS-1154
  2. https://java.net/jira/browse/JAX_WS_COMMONS-132



回答4:


wsimport -keep -verbose -httpproxy:172.18.14.192:8089 http://xxx.abc.com/services/s1?wsdl

As per Oracle JAVA 9 wsimport documentation




回答5:


You can use --httpproxy option of wsimport option too-

wsimport -keep -httpproxy:USERNAME:passwdsabc001@proxy.yourcmpny.com




回答6:


Approach suggested by Neil Kennedy would work if you can set that flag at application level.However if you want to use proxy for specific url then have look at ProxySelector class. You can write your own proxy selector class which extends ProxySelector with your proxy host and port and then set it as default proxy selector.Have a look at this thread How can I use an HTTP proxy for a JAX-WS request without setting a system-wide property? for answer given by Uncle Iroh. Also have look at http://docs.oracle.com/javase/7/docs/technotes/guides/net/proxies.html for details of Proxyselector which clearly explains what is happening.



来源:https://stackoverflow.com/questions/10298699/how-do-i-tell-wsimport-to-use-a-proxy-exception-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!