AsyncHttpClient始终因内部服务器错误而失败

时间:2014-06-05 04:57:40

标签: android ios android-async-http

我是Android平台上的首发,我只是将iOS应用程序移植到Android.In iOS我使用AFNetworking访问Web服务。在Android中我发现我正在使用AsyncHttpClient并尝试与服务器通信(文本json数据接受)。但总是得到"内部服务器错误"在Android中,在iOS平台上运行良好。任何人都可以帮助调试问题。

代码:

RequestParams params = new RequestParams();
HashMap<String, String> param = new HashMap<String, String>();
param.put("Username","test123");

params.put("Message",param);
params.put("Name","ValidateUserName");

StringEntity entity = null;
JSONObject jsonParams = new JSONObject();
jsonParams.put("Message",param);
jsonParams.put("Name","ValidateUserName");

entity = new StringEntity(jsonParams.toString());

AsyncHttpClient client = new AsyncHttpClient();
Context context = this.getApplicationContext();

client.post(context,"http://10.1.124.107/sample/test/Login/Validateusername, entity,      “application/json",
                    new AsyncHttpResponseHandler(){
                @Override
                public void onSuccess(String response) {
                    Log.d("HTTP", "onSuccess: " + response);
                }


                @Override
                public void onFailure(Throwable e, String response) {
                     Log.d(“FAILURE”,e.toString());
                }


            });

错误:

06-05 00:34:37.895: V/FAILURE(1301): org.apache.http.client.HttpResponseException: Internal Server Error

0 个答案:

没有答案