java - Spring - 通过代理引导所有出站流量

标签 java spring web-services spring-mvc proxy

我有一个 Spring 应用程序,使用 spring-ws 来处理所有 SOAP 消息,在我的本地开发计算机上运行得很好。当我部署到需要使用代理才能到达外界的任何流量的服务器时,我似乎陷入了困境。我的印象是我可以设置一些 JVM 参数,例如

-Dhttp.proxyHost=proxyhostURL 
-Dhttp.proxyPort=proxyPortNumber 
-Dhttp.proxyUser=someUserName 
-Dhttp.proxyPassword=somePassword

但是类文件似乎不支持 proxyUser 和 proxyPassword 参数。

我什至更进一步,在 java 代码本身中实现了它:

System.getProperties().put("http.proxyHost", "someProxyURL");
System.getProperties().put("http.proxyPort", "someProxyPort");
System.getProperties().put("http.proxyUser", "someUserName");
System.getProperties().put("http.proxyPassword", "somePassword");

但还是没有运气。

然后我尝试使用 java.net.Authenticator 来设置用户名和密码,但这似乎也不起作用:

Authenticator.setDefault(
                  new Authenticator() {
                    public PasswordAuthentication getPasswordAuthentication() {
                      return new PasswordAuthentication(authUser, authPassword.toCharArray());
                    }
                  }
                );

有人对如何使用 Java6、Tomcat 6 和 Spring 3(带有 spring-ws)通过代理路由所有流量有任何建议

最佳答案

事实证明,它没有遵守传入的 JVM HTTP 参数,因为我的 Web 服务正在使用 HTTPS。将标志设置为以下内容后:

-Dhttps.proxyHost=proxyhostURL 
-Dhttps.proxyPort=proxyPortNumber 
-Dhttps.proxyUser=someUserName 
-Dhttps.proxyPassword=somePassword

一切都按计划进行。

关于java - Spring - 通过代理引导所有出站流量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24813947/

相关文章:

java - WSO2 ESB 添加带有自定义证书的安全端点

java - Idea中读取属性文件出现空指针异常

java - Tomcat V8 无法在 Eclipse 中启动 - 严重 : A child container failed during start

java - Log4j FileNotFoundException - Java FileSystem getBooleanAttributes() 方法如何工作?

spring - 由 : java. lang.IllegalStateException 引起:您需要为 git 存储库配置 uri

spring - Quartz 作业在 Tomcat 6/Ubuntu 10.04LTS 上部署时运行两次

java - 创建游戏启动器时出错

java - 使用 Gradle 构建时出错 : Cause: error=2, 没有这样的文件或目录

java - 使用 JMS 为 Web 应用程序长时间运行的文件创建过程

node.js - 将 http 重定向到 https express.js