我使用rest很容易从第三方URL获取和发布数据,当我使用下面的代码调用get服务时,我得到了ClassNotFoundException"javax.net.ssl.SSLSocketFactory"
final ClientRequest request = createRequest(url,acceptType,consumesType,body);
final byte[] encodedCredentials = (userName + ":" + password)
.getBytes();
final String encodedAuto = Base64.encodeBytes(encodedCredentials);
request.header("Authorization", "Basic " + encodedAuto);
try {
request.addAuthenticationHeaders(request, userName,
password);
response = request.get(String.class);
if (response != null) {
logger.info("Status of the REST Call:"
+ response.getStatus());
}
} catch (final Exception e) {
e.printStackTrace();
logger.error("Failed the get the data from PM", e);
}
Run Code Online (Sandbox Code Playgroud)
createRequest方法如下所示
public ClientRequest createRequest(final String urlString,
final String acceptType, final String consumesType,
final String body) {
final …Run Code Online (Sandbox Code Playgroud)