简体   繁体   English

如何告诉wsimport在生成的类中使用httpproxy

[英]How to tell wsimport to use an httpproxy into generated classes

With wsimport command included in JDK6 it is possible to generate the Java classes needed to invoke a Web Service, starting from it's WSDL. 使用JDK6中包含的wsimport命令,可以从Web服务的WSDL开始生成调用Web服务所需的Java类。

Once these classes are generated however, they may be used from within a network with an Http-Proxy . 但是,一旦生成了这些类,便可以在带有Http-Proxy的网络中使用它们。

The optimal solution for this should be to leverage the URL.openConnection(Proxy proxy) API instead of other system-wide (via system properties or with a ProxySelector) methods. 对此的最佳解决方案应该是利用URL.openConnection(Proxy proxy) API而不是其他系统范围内(通过系统属性或使用ProxySelector)方法。

Is it possible to tell the wsimport command to use a given http-proxy into the generated code? 是否可以告诉wsimport命令在生成的代码中使用给定的http-proxy?

Please note that among the wsimport option there is also -httpproxy:<host>:<port> , but this is used only for allowing the generation behind an Http Proxy and the option has no effect on generated code. 请注意, 在wsimport选项中还有-httpproxy:<host>:<port> ,但这仅用于允许在Http Proxy之后进行生成,并且该选项对生成的代码无效。 Further, looking at the generated classes there is not even an explicit call to URL.openConnection(), so apparently there is no way to override this behaviour. 此外,查看生成的类,甚至没有对URL.openConnection()的显式调用,因此,显然没有任何方法可以覆盖此行为。

I think that there is no way to actually generate stubs with the proxy they are going to be used with. 我认为没有办法使用将与之一起使用的代理实际生成存根。 In fact why they should be? 其实为什么要这样? Stubs are just stubs, a representation derived from wsdl. 存根只是存根,一种从wsdl派生的表示形式。 Why should they know about proxy? 他们为什么要了解代理? If the same application is moved to other system with different proxy, then code needs to be changed ie stubs needs to be generated again with the knowledge of new proxy. 如果将同一应用程序移动到具有不同代理的其他系统,则需要更改代码,即需要在了解新代理的情况下再次生成存根。 This is clearly undesirable. 这显然是不可取的。 So in my knowledge I don't think that's even a possibility. 因此,据我所知,我什至没有这种可能性。

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

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