Proxy weblogic.net.http.HttpUnauthorizedException:需要代理或服务器身份验证
我正在尝试连接到部署在weblogic 10.3.6上的应用程序中的REST API。示例代码在独立运行(在weblogic服务器外部)时运行良好。但是当我部署相同的代码时,它开始给我这个错误 无法与代理通信:proxy.xxx.xxx/xxxx。现在将尝试连接api.forecast.io/443。 weblogic.net.http.HttpUnauthorizedException:需要代理或服务器身份验证 位于weblogic.net.http.HttpURLConnection.getAuthInfo(HttpURLConnection.java:297) 位于weblogic.net.http.HttpsClient.MakeConnectionSingProxy(HttpsClient.java:440) 位于weblogic.net.http.HttpsClient.openServer(HttpsClient.java:351) 位于weblogic.net.http.HttpsClient.New(HttpsClient.java:527) 位于weblogic.net.http.HttpsURLConnection.connect(HttpsURLConnection.java:239) 我们正在运行的代码如下所示Proxy weblogic.net.http.HttpUnauthorizedException:需要代理或服务器身份验证,proxy,weblogic,Proxy,Weblogic,我正在尝试连接到部署在weblogic 10.3.6上的应用程序中的REST API。示例代码在独立运行(在weblogic服务器外部)时运行良好。但是当我部署相同的代码时,它开始给我这个错误 无法与代理通信:proxy.xxx.xxx/xxxx。现在将尝试连接api.forecast.io/443。 weblogic.net.http.HttpUnauthorizedException:需要代理或服务器身份验证 位于weblogic.net.http.HttpURLConnection.get
try {
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
SSLContext context = SSLContext.getInstance("TLS");
context.init(null, new X509TrustManager[] { new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] chain,
String authType) throws CertificateException {
}
public void checkServerTrusted(X509Certificate[] chain,
String authType) throws CertificateException {
}
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
} }, new SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory());
} catch (Exception e) { // should never happen
e.printStackTrace();
}
try {
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxy.xxxx.xxxx", xxxx));
URL url = new URL("https://api.forecast.io/forecast/xxxxxxxxx/12.9667,77.5667");
HttpURLConnection conn = (HttpURLConnection)url.openConnection(proxy);
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "application/json");
if (conn.getResponseCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));
String output;
System.out.println("Output from Server .... \n");
while ((output = br.readLine()) != null) {
System.out.println(output);
}
conn.disconnect();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return "";
我们的代理是公司代理,没有任何用户名/密码。我们在这个问题上陷入困境已有一段时间了。任何建议/建议都将不胜感激。您的公司可能正在运行某种自动配置脚本?尝试在代码中设置PAC脚本,如以下问题所示: