2013-04-18 1 views
2

나는 ulr에서 json 데이터를 가져 오려고합니다.android에서 전체 http 응답을받지 못합니다

나는 firefox 포스터에 추가 기능이 제대로 작동하는지, 전체 응답으로 테스트 중입니다.

하지만 안드로이드는 전체 http 응답을받지 못합니다.

나는 또한 구글에서 검색 및 코드를 시도하지만 내 문제가 해결되지 오전

HttpClient client = new DefaultHttpClient(); 
HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000); // Timeout 
                     // Limit 
HttpResponse response; 
JSONObject json = new JSONObject(); 

try { 
    HttpPost post = new HttpPost(API.ALL_PROPERTY_BUY); 

    /* 
    * json.put("fId", fname); json.put("fId", lname); 
    */ 
    StringEntity se = new StringEntity(json.toString()); 
    se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE,"application/json")); 
    post.setEntity(se); 
    response = client.execute(post); 

    /* Checking response */ 
    if (response != null) { 
     InputStream in = response.getEntity().getContent(); // Get the 
                  // data in 
                  // the 
                  // entity 
     // System.out.println("Response is:"+ in.toString()); 
     InputStreamReader isr = new InputStreamReader(in); 
     BufferedReader br = new BufferedReader(isr); 

     String s = new String(); 
     temps = new String(); 
     while ((s = br.readLine()) != null) { 
      System.out.println("response is :" + s); 

     } 



    } 


} catch (Exception e) { 
    e.printStackTrace(); 

} 

이 내 코드입니다.

아무쪼록 도와주세요.

+0

매니페스트 파일에 인터넷 권한을 추가하십시오. –

+0

@VivekKumarSrivastava 모든 권한 추가 및 코드 잘 작동하지만 문제가 webservice에서 전체 응답을 받고 있지 않습니다. – Hemant

+0

String을 사용할 수 있습니다. EntityUtils.toString (response.getEntity()); 이 작품이 나에게 알려주세요. –

답변

2

이 시도 ...

StringBuffer stringBuffer = new StringBuffer(); 
      while ((s = br.readLine()) != null) { 
       stringBuffer.append(s); 
      } 

System.out.println("response is :" + stringBuffer); 

때로는 자사의 콘솔에서 전체 응답을 인쇄하지만 당신은 당신의 변수에 전체 응답을받지 ...

솔루션 : 전체 데이터 로그 캣 또는 콘솔에 표시되지

+0

작동하지만 응답이 충분하지 않습니다. – Hemant

+1

귀하의 응답은 변수의 한계에 비해 매우 큽니까? 응답이 절반이되거나 응답 pls가 지정되지 않는 것을 의미합니다 ...? 감사 응답 – SBJ

+0

반 응답 받고. 내 응답 크기가 매우 큽니다. – Hemant

관련 문제