我有一个 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/