我有一個java web服務,如果登錄成功,必須返回響應無法打印JSON-RPC響應
服務器端方法的返回線
return new Response(new InfoSessionJson(newKey, is), null, id);
獲得響應我曾嘗試使用代碼
HttpResponse response = mClient.execute(httppost);
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
if(response != null){
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
loggato=true;
try {
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
System.out.println("The response is "+sb.toString());
但輸出打印返回Apache的錯誤
我試圖打印的
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
直接輸出與
System.out.print(entity);
System.out.print(response);
這種打印:
[email protected] org.apache .http.message.BasicHttpResponse @ 40574a00
錯誤在哪裏?
我無法正確解析響應或問題出現在?
WebService的方法有這個FIM
@Webservice(paramNames = {"email", "password", "stayLogged", "idClient"},
public Response startSession(String email, String password, Boolean stayLogged, String idClient)
我送一個JSON與
StringEntity stringEntity = new StringEntity(jsonObject.toString());
httpost.setEntity(stringEntity);
httpost.setHeader("Accept", "application/json");
httpost.setHeader("Content-type", "application/json");
如果發送的JSON對象是
{"method":"startSession","params":[{"email":"[email protected]","password":"1234","idClient":"ANDROID","stayLogged":"1"}]}
的web服務工作正常使用iOS應用程序,但不會與我的Android應用程序,
我在此線程中描述的過程中的錯誤在哪裏?
我希望有人能幫助我。
謝謝你,我已經糾正這一錯誤並打印一些東西......但錯誤,而不是正確的響應與會話密鑰,我不明白爲什麼 – AndreaF 2012-03-03 18:00:00