日期:2014-05-20 浏览次数:21035 次
//String https_url = "https://localhost:9001/init?playerId=3344";
String https_url = "https://localhost:9001/play?playerId=3344";
URL url;
try {
url = new URL(https_url);
HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setRequestMethod("POST");
OutputStreamWriter output = new OutputStreamWriter(con.getOutputStream());
String postData=
"<TransactionId>"
+ "13256477107065"
//这个id是https_url为注释掉的那个init URL返回的结果,我直接copy放在这里
+ "</TransactionId>";
output.write(postData);
output.flush();
System.out.println("****** Content of the URL ********");
BufferedReader br =
new BufferedReader(
new InputStreamReader(con.getInputStream()));
String input;
while ((input = br.readLine()) != null){
System.out.println(input);
}
br.close();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}