java Axis HTTP 与 Axis HTTPS 代理设置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15098044/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 18:28:17  来源:igfitidea点击:

Axis HTTP Vs Axis HTTPS Proxy Settings

javaweb-servicesproxyaxisproxy-classes

提问by Sankalp

My Java application deployed on Weblogic Cluster invokes two Webservices which are as follow.

我部署在 Weblogic 集群上的 Java 应用程序调用了两个 Web 服务,如下所示。

? It sents SOAP Client request to External Application which is on internet) over HTTPS.(Java Classes created through Axis 1.4)

? 它通过 HTTPS 将 SOAP 客户端请求发送到 Internet 上的外部应用程序。(通过 Axis 1.4 创建的 Java 类)

? Thereafter It sents SOAP Client request to internal Application(present on the other node which is connected to my LAN) over HTTP.(Java Classes created through JAX-WS:Jdeveloper Wizard)

? 此后,它通过 HTTP 将 SOAP 客户端请求发送到内部应用程序(存在于连接到我的 LAN 的另一个节点上)。(通过 JAX-WS 创建的 Java 类:Jdeveloper Wizard)

In order to reach the 1st WS, I have to set the https proxy settings for the web service client using the following code:

为了达到第一个 WS,我必须使用以下代码为 Web 服务客户端设置 https 代理设置:

System.setProperty("https.proxyHost", myProxyIP);  
System.setProperty("https.proxyPort", myProxyPort);  

Whereas the 2nd Web services doesn't need this proxy setting because they're already reachable on the network.

而第二个 Web 服务不需要此代理设置,因为它们已经可以在网络上访问。

My problem is as follows:

我的问题如下:

If I call the 1st service (the one with the proxy setting), and then call the other , the Axis client tries to call these services with the same proxy setting, even if I remove the proxy setting from the System properties just before I am about to inoke the 2ns WS by writing

如果我调用第一个服务(具有代理设置的服务),然后调用另一个服务,Axis 客户端会尝试使用相同的代理设置调用这些服务,即使我在我之前从系统属性中删除了代理设置即将通过写入来调用 2ns WS

 System.setProperty("http.proxySet", "false");  
    System.getProperties().remove("http.proxyHost");  
    System.getProperties().remove("http.proxyPort");  
    AxisProperties.setProperty("http.proxyHost", null);  
    AxisProperties.setProperty("http.proxyPort", null);

I read somwhere to use nonProxyHosts.But I am confused if should i write

我在某处读到使用 nonProxyHosts。但我很困惑我是否应该写

System.setProperty("https.nonProxyHosts","secws.secondwsint.com");

or

或者

System.setProperty("http.nonProxyHosts","secws.secondwsint.com");

http ot https, since the one that need to be bypassed is HTTP and the one we are setting proxy is HTTPS.

http ot https,因为需要绕过的是HTTP,而我们设置代理的是HTTPS。

I also read in one of blog:

我还在其中一篇博客中读到:

AxisProperties.setProperty("https.proxyHost", "bla1.bla1"); 
AxisProperties.setProperty("https.proxyPort", "8080"); 
AxisProperties.setProperty("https.nonProxyHosts", "secws.secondwsint.com"); 

but again confued wheather to use https.nonProxyHosts or http.nonProxyHosts

但再次混淆是否使用 https.nonProxyHosts 或 http.nonProxyHosts

Which one would be advisable to use in my java program System.setPropertyor AxisProperties.setPropertyand importantly should i use http ot https for writing that codeline Also, Is there any other alternative?

建议在我的 java 程序中使用哪一个,System.setProperty或者AxisProperties.setProperty重要的是我应该使用 http ot https 来编写该代码行 另外,还有其他选择吗?

回答by Lan

You can use both. But The System.setProperty() will also affect other HTTP related java function in your VM, while AxisProperties only affects Axis WS client. So I will pick AxisProperties.setProperty().

您可以同时使用两者。但是 System.setProperty() 也会影响 VM 中其他与 HTTP 相关的 java 函数,而 AxisProperties 仅影响 Axis WS 客户端。所以我会选择AxisProperties.setProperty()。

There is a bug in Axis problem with http proxy parameters caching mechanism. Basically the implementation caches the old proxy setting and does not read new settings. So even if you use AxisProperties.setProperty()method, it still does not work. I am not sure if it applies to Axis 1.4 or not, as the JIRA does not provide affected version number.

http 代理参数缓存机制存在 Axis问题中的一个错误。基本上实现缓存旧的代理设置并且不读取新设置。所以即使你使用AxisProperties.setProperty()方法,它仍然不起作用。我不确定它是否适用于 Axis 1.4,因为 JIRA 不提供受影响的版本号。

I also believe you should set http.nonProxyHosts because your internal WS uses HTTP, not HTTPS. But in another post, you mentioned that you set both and it does not work. Is that still the case?

我也相信你应该设置 http.nonProxyHosts 因为你的内部 WS 使用 HTTP,而不是 HTTPS。但是在另一篇文章中,您提到您设置了两者,但它不起作用。还是这样吗?