2013-11-14 3 views
0

안드로이드 코드HTTP 500 내부 서버 오류

class BirthdayTask extends AsyncTask<String, String, String>{ 

     @Override 
     protected String doInBackground(String... uri) { 
      HttpClient httpclient = new DefaultHttpClient(); 
      HttpResponse response; 
      String responseString = null; 
      try { 
       System.out.println(uri[0]); 
       response = httpclient.execute(new HttpGet(uri[0])); 
       StatusLine statusLine = response.getStatusLine(); 
       if(statusLine.getStatusCode() == HttpStatus.SC_OK){ 
        ByteArrayOutputStream out = new ByteArrayOutputStream(); 
        response.getEntity().writeTo(out); 
        out.close(); 
        responseString = out.toString(); 
        System.out.println("responseString"+responseString); 
       } else{ 
        //Closes the connection. 
        response.getEntity().getContent().close(); 
        throw new IOException(statusLine.getReasonPhrase()); 
       } 
      } catch (ClientProtocolException e) { 
       //TODO Handle problems.. 
      } catch (Exception e) { 
       e.printStackTrace(); 
      } 
      return responseString; 
     } 


     @Override 
     protected void onPostExecute(String result) { 
      super.onPostExecute(result); 
      /* System.out.println(result); 
      System.out.println(result); 
      System.out.println(result);*/ 
     } 

    } 


@RequestMapping(value="here is my url" ,method=RequestMethod.GET) 
     public @ResponseBody String Test(HttpServletRequest req) { 

      Gson gson = new Gson(); 

      Domain domain = (Domain)req.getSession().getAttribute("Domain"); 
      List<UserProfile> userProfiles = userProfileManager.getUpcomingBirthday(domain.getDomainId(),15); 

      return gson.toJson(userProfiles); 
     } 

Webservice를

이 내가이 잘 woriking broweser에서 전화를하고 웹 서비스입니다 .... 그러나 나는 다음 안드로이드에서 500 내부 서버를 호출하고 때 오류 ....하지만 서버에 아무런 오류도 기록하지 않았습니다. .....이 문제에 대한 해결책을 찾으십시오. 미리 감사드립니다.

+0

서버 측에서 어떻게 든 디버깅 할 수 있습니까? 또는 어떤 정보를 더 제공합니까? –

답변

1

답변을 제공하기가 어렵지만 Android를 사용하여 WS를 호출 할 때 세션이 null이라고 생각합니다. 브라우저를 사용하여 WS를 호출하는 경우 세션은 쿠키 또는 sessionId를 사용하여 유지 될 수 있지만 쿠키 또는 sessionId를 처리하는 코드 행은 찾을 수 없습니다. IMO 세션 정보에 의존해서는 안됩니다. 호프가 도움이되기를 바랍니다.

+0

고마워요 ...... 아침부터이 문제에 직면 해 있습니다. –