内部服务器错误在服务器和iOS中正常工作

时间:2014-02-20 22:16:08

标签: android json node.js http-post

我正在尝试调用后端节点js服务器。 虽然在iOS和服务器上工作正常但我得到内部错误作为响应。服务器将响应代码发送回500并显示错误消息数据。如何解析错误响应代码并解析json错误消息。所有错误消息都转到异常 代码:

httpPostRequest.setEntity(se);
        HttpResponse response = null;
        try {
            response = client.execute(httpPostRequest);
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            Toast.makeText(getApplicationContext(),
                    "Please check your internet connection",
                    Toast.LENGTH_SHORT).show();
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        BasicResponseHandler responseHandler = new BasicResponseHandler();
        String strResponse = null;
        if (response != null) {
            try {
                strResponse = responseHandler.handleResponse(response);
            } catch (HttpResponseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        Log.e("BackEndServer ", "Response: " + strResponse);

日志:

02-20 12:21:44.870: W/System.err(29129): org.apache.http.client.HttpResponseException: Internal Server Error
02-20 12:21:44.870: W/System.err(29129):    at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:71)
02-20 12:21:44.870: W/System.err(29129):    at com.amazonaws.androidtest.MessageReceivingService.sendRegistrationIdToBackend(MessageReceivingService.java:165)
02-20 12:21:44.870: W/System.err(29129):    at com.amazonaws.androidtest.MessageReceivingService.access$1(MessageReceivingService.java:123)
02-20 12:21:44.870: W/System.err(29129):    at com.amazonaws.androidtest.MessageReceivingService$1.doInBackground(MessageReceivingService.java:111)
02-20 12:21:44.870: W/System.err(29129):    at android.os.AsyncTask$2.call(AsyncTask.java:252)
02-20 12:21:44.870: W/System.err(29129):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
02-20 12:21:44.870: W/System.err(29129):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
02-20 12:21:44.880: W/System.err(29129):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1081)
02-20 12:21:44.880: W/System.err(29129):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:574)
02-20 12:21:44.880: W/System.err(29129):    at java.lang.Thread.run(Thread.java:1020)
02-20 12:21:44.880: E/BackEndServer(29129): Response: null

0 个答案:

没有答案