开发者

Internal Error when executing a JSON request

I'm developing an application which communicate with a server through JSON messages.

Some messages was send and received the result properly. But one of my routines thrown an Error and I'm not sure if it is my problem or from the server.

The error is:

 org.apache.http.client.HttpResponseException: Internal Server Error
     at org.apache.http.impl.client.BasicResp开发者_JAVA百科onseHandler.handleResponse(BasicResponseHandler.java:71)
     at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:59)
     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:657)
     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:627)
     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:616)
     at br.com.iba.dao.DLS.post(DLS.java:121)
     at br.com.iba.dao.DLS.fulfill(DLS.java:151)
     at br.com.iba.LibraryActivity$3.doAction(LibraryActivity.java:123)
     at br.com.iba.LibraryActivity$SwitchListener.setSelected(LibraryActivity.java:208)
     at br.com.iba.LibraryActivity$SwitchListener.access$0(LibraryActivity.java:204)
     at br.com.iba.LibraryActivity$ButtonGroup.onClick(LibraryActivity.java:230)
     at android.view.View.performClick(View.java:2408)
     at android.view.View$PerformClick.run(View.java:8816)
     at android.os.Handler.handleCallback(Handler.java:587)
     at android.os.Handler.dispatchMessage(Handler.java:92)
     at android.os.Looper.loop(Looper.java:123)
     at android.app.ActivityThread.main(ActivityThread.java:4627)
     at java.lang.reflect.Method.invokeNative(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:521)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
     at dalvik.system.NativeStart.main(Native Method)

My code to post is this:

    private String post(String json) {
        int TIMEOUT_MILLISEC = 10000; // = 10 seconds
        HttpParams httpParams = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(httpParams, TIMEOUT_MILLISEC);
        HttpConnectionParams.setSoTimeout(httpParams, TIMEOUT_MILLISEC);
        HttpClient client = new DefaultHttpClient(httpParams);

        HttpPost request = new HttpPost(
                "https://my server url");
        try {
            StringEntity entity = new StringEntity(json);
            entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE,
                    "application/json"));
            request.setEntity(entity);

            ResponseHandler<String> handler = new BasicResponseHandler();
            return client.execute(request, handler);
        } catch (Throwable e) {
            e.printStackTrace();
            return "";
        }
    }

I read on BasicResponseHandler Doc:

"A ResponseHandler that returns the response body as a String for successful (2xx) responses. If the response code was >= 300, the response body is consumed and an HttpResponseException is thrown. If this is used with {@link org.apache.http.client.HttpClient#execute( org.apache.http.client.methods.HttpUriRequest, ResponseHandler), HttpClient may handle redirects (3xx responses) internally."

So now I believe it was an server side error. I need to know which exactly error is that.

Thanks


Your server is returning a 500 Internal Server Error response status. So the issue is on your server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜