gpt4 book ai didi

java - 如何配置代理设置?

转载 作者:行者123 更新时间:2023-12-01 13:31:17 27 4
gpt4 key购买 nike

我调用了具有代理设置的 Web 服务,因此我为基于 http 的 Web 服务执行了以下代码:

System.setProperty("http.proxyHost","10.0.0.1");
System.setProperty("http.proxyPort","222");
System.setProperty("http.proxyUser","xyz");
System.setProperty("http.proxyPassword","pqr");// base64 password.

但是当我对基于 https 的网络服务使用相同的代码时:

System.setProperty("https.proxyHost","10.0.0.1");
System.setProperty("https.proxyPort","222");
System.setProperty("https.proxyUser","xyz");
System.setProperty("https.proxyPassword","pqr");// base64 password.

它给了我以下异常:

Caused by: java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.0 407 Proxy Authentication Required"

或者还有其他方式调用Https webservice吗?

谢谢你..

最佳答案

Try this and let me know that helps.. 

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

http://viralpatel.net/blogs/http-proxy-setting-java-setting-proxy-java/

关于java - 如何配置代理设置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21550637/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com