【发布时间】:2016-08-28 12:02:01
【问题描述】:
我使用 SOAP UI 创建了一个休息模拟服务。 我正在尝试从我的 java 类中连接它。但它失败并出现错误
Open connection failed: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
sun.security.ssl.InputRecord.handleUnknownRecord(Unknown Source)
sun.security.ssl.InputRecord.read(Unknown Source)
sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
我不确定我哪里出错了。
下面是代码 -
java.net.URL url = new URL(null, address,new sun.net.www.protocol.https.Handler());
connection = (javax.net.ssl.HttpsURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "text/xml");
connection.setRequestMethod("GET");
connection.connect();
我尝试连接的 URL 是 - http://localhost:8089
【问题讨论】:
-
您正在混合使用 HTTP 和 HTTPS 的东西。模拟服务是否通过 SOAP UI 通过 SSL 公开?您只需要将地址变量方案更改为 HTTPS。 SOAP UI 是否通过 HTTP 公开模拟?您必须使用 URLConnection 而不是 HttpsURLConnection
-
不,我的 mockservice 没有通过 SSL 公开,我该怎么做?请给我建议。