我有一个java spring mvc应用程序,它有api服务,我们也在网站上使用ssl。 api读取json并将输出作为json。如果没有网址中的https协议,一切正常。
尝试使用post参数作为json调用https://example.com/appname/apiurl来使用web服务。
这是api方法
BufferedReader br = null;
ServerSocket serverSocket = null;
String json = "";
try {
serverSocket = new ServerSocket(8443);
Socket clientSocket = serverSocket.accept();
br = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
System.out.println("Client said :" + br.readLine());
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
serverSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
//BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream()));
if (br != null) {
json = br.readLine();
}
// 2. initiate jackson mapper
ObjectMapper mapper = new ObjectMapper();
anulomtrnstatus anulompbean = null;
// 3. Convert received JSON to Article
try {
anulompbean = mapper.readValue(json, beanclass.class);
} catch (Exception e) {
e.printStackTrace();
}
这是错误控制台。
org.apache.http.conn.ConnectTimeoutException:连接到192.168.0.104:8443 [/192.168.0.104]失败:连接超时