Java Jersey客户端API-读取数据
我正在使用Jersey客户端API读取数据,但下面的代码引发以下异常: 线程“main”com.sun.jersey.api.client.clienthandler异常:Java Jersey客户端API-读取数据,java,web-services,jaxb,jersey,jax-ws,Java,Web Services,Jaxb,Jersey,Jax Ws,我正在使用Jersey客户端API读取数据,但下面的代码引发以下异常: 线程“main”com.sun.jersey.api.client.clienthandler异常: String url = "XXXX"; String name = "UserName"; String password = "Password"; String authString = name + ":" + password; String authStringEn
String url = "XXXX";
String name = "UserName";
String password = "Password";
String authString = name + ":" + password;
String authStringEnc = new BASE64Encoder().
encode(authString.getBytes());
ObjectMapper mapper = new ObjectMapper();
String resp;
System.out.println("Base64 encoded auth string: " + authStringEnc);
Client restClient = Client.create();
WebResource webResource = restClient.resource(url);
ClientResponse clientResp = webResource.accept("application/json").
header("Authorization", "Basic " + authStringEnc).get
(ClientResponse.class);
resp = clientResp.getEntity(String.class);
System.out.println("response: " + resp);
if(clientResp.getStatus() != 200){
System.err.println("Unable to connect to the server");
}
try {
SNApplicationLst snApplnLst = mapper.readValue(resp,
SNApplicationLst.class);
for(SNApplication snAppln: snApplnLst.getResult()) {
System.out.println("name:" + snAppln.getName()
+ " :: application_id:" + snAppln.getU_application_id());
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
输出:运行代码上方的代码后,抛出异常。谁能帮我一下吗
Exception in thread "main"
com.sun.jersey.api.client.ClientHandlerException:
java.net.SocketException: Connection reset
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle
(URLConnectionClientHandler.java:151)
at com.sun.jersey.api.client.Client.handle(Client.java:648)
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:680)
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
at com.sun.jersey.api.client.WebResource$Builder.get
(WebResource.java:507)
at sailpoint.custom.Test.main(Test.java:41)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at sun.security.ssl.InputRecord.readFully(Unknown Source)
at sun.security.ssl.InputRecord.read(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect
(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown
Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown
Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode
(Unknown Source)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke
(URLConnectionClientHandler.java:249)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle
(URLConnectionClientHandler.java:149)
... 5 more
什么是完整堆栈跟踪?将此评论作为编辑添加到原始帖子中。什么是完整堆栈跟踪?将此评论作为编辑添加到原始帖子中。