【发布时间】:2015-03-24 10:20:20
【问题描述】:
我想连接到一个 https url https://www.ovh.com/cgi-bin/sms/http2sms.cgi,我使用了以下代码:
URL ovhUrl = new URL("https://www.ovh.com/cgi-bin/sms/http2sms.cgi");
HttpsURLConnection connection = (HttpsURLConnection)ovhUrl.openConnection(); // error here
String s_getBody = String.format("account=%s&login=%s&password=%s&from=%s&to=%s&message=%s",
URLEncoder.encode(account, "UTF-8"),
URLEncoder.encode(login, "UTF-8"),
URLEncoder.encode(password, "UTF-8"),
URLEncoder.encode(from, "UTF-8"),
URLEncoder.encode(to, "UTF-8"),
URLEncoder.encode(msg, "UTF-8"));
但是,每次执行它时,都会在第二行出现异常:
weblogic.net.http.SOAPHttpsURLConnection cannot be cast to javax.net.ssl.HttpsURLConnection
我正在使用 Weblogic Server,我在这里找到了添加到类路径的解决方案,但我宁愿不更改应用程序的类路径或摆弄 Weblogic Server。是否有另一种方法来解决它,也许是通过使用另一个类或另一种方法来执行 https url?
【问题讨论】:
-
URL到底是什么类型? Weblogic 还是 java?
标签: java url https weblogic httpsurlconnection