0
私は、サーバーにjson要求を投稿するときに、応答を出力するときは常に[email protected]を返すという質問がありますこの反応の手段は?json postからの応答
コード:サーバーから取得
HttpClient client = new DefaultHttpClient();
HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000); //Timeout Limit
HttpResponse response;
JSONObject json = new JSONObject();
try{
HttpPost post = new HttpPost("http://122.180.114.68/eqixmobile/siteservice/um/ibx");
json.put("username", ed_usrName.getText().toString());
json.put("password", ed_pass.getText().toString());
post.setHeader("Content-Type", "application/json");
post.setHeader("Accept", "application/json");
StringEntity se = new StringEntity("credentials: " + json.toString());
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
post.setEntity(se);
response = client.execute(post);
/*Checking response */
if(response!=null){
InputStream in = response.getEntity().getContent();
//String str = response.getEntity().getContent().toString();//Get the data in the entity
System.out.println("This is service response:"+in);
}
else
{
System.out.println("This is no any service response:");
}
}
catch(Exception e){
e.printStackTrace();
//createDialog("Error", "Cannot Estabilish Connection");
}
あなたは、インターネットのアクセス許可を与えていません最初? –