简体   繁体   English

如何告诉wsimport使用代理例外URL

[英]How do I tell wsimport to use a proxy exception url

I need to connect to an internal intranet web service. 我需要连接到内部Intranet Web服务。 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. 我可以在IE和Firefox中导航到WSDL,但我必须在两个浏览器中将地址添加到代理例外列表中。

When I use wsimport I cannot get the WSDL because of the proxy server. 当我使用wsimport时,由于代理服务器,我无法获得WSDL。 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. 添加或删除-httpproxy arg给我一个错误“无法通过代理隧道”所以我猜这不是我需要这样做的方式。

Does anyone know a way I can tell wsimport to ignore the proxy server for this url? 有没有人知道我可以告诉wsimport忽略这个网址的代理服务器?

Neil 尼尔

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). 我在这篇文章中找到了一种方法,使用代理内部(内部网)URL和使用wsimport.exe(JDK 1.6,1.7等的一部分)跳过外部URL代理(w3c.com)。 I see that it does not have the facility to put nonProxyHosts, so I went ahead and used Java class invocations. 我发现它没有放置nonProxyHosts的功能,所以我继续使用Java类调用。

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. 请记住,“-Dhttp.nonProxyHosts”仅在您之前在该行中配置代理时才有效,您需要所有参数。 So, if you just want to disable a default proxy you have to configure it here again. 因此,如果您只想禁用默认代理,则必须再次在此处进行配置。

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. 您需要将以下内容添加为JVM参数,并使用Internet Explorer(或Mac上的Safari我假设)代理地址和排除列表。

-Djava.net.useSystemProxies=true

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

Currently wsimport is broken in this regard. 目前, wsimport在这方面已被打破。

I created two tickets for that: 我创建了两张票:

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

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. 如果您可以在应用程序级别设置该标志,那么Neil Kennedy建议的方法将起作用。但是,如果您想使用特定URL的代理,那么请查看ProxySelector类。 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? 您可以编写自己的代理选择器类,使用代理主机和端口扩展ProxySelector,然后将其设置为默认代理选择器。看看此线程如何不设置系统的情况下将HTTP代理用于JAX-WS请求 -广泛的财产? for answer given by Uncle Iroh. 由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. 另请查看http://docs.oracle.com/javase/7/docs/technotes/guides/net/proxies.html ,了解Proxyselector的详细信息,它清楚地解释了正在发生的事情。

您也可以使用wsimport选项的--httpproxy选项 -

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

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

根据Oracle JAVA 9 wsimport文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM