Android org.apache.http.client.HttpResponseException:Not Found

时间:2013-12-09 18:34:10

标签: android androidhttpclient

在我的应用程序中,我将用户信息发送到服务器,http如下,我得到 org.apache.http.client.HttpResponseException:Not Found ,我花了更多时间但无法解决问题。请帮我找出解决方案。

我在这一行得到错误:

jsonResponse = httpClient.execute(httpPost,resHandler);

public String addNewCardDetail(String loggedin_id, String fn, String ln,
        String cardholdername, String cardno,String cvv, String expdate, String add,
        String state, String city, String pincode) {

    jsonResponse = "";

    httpClient = new DefaultHttpClient();
    resHandler = new BasicResponseHandler();
    httpPost = new HttpPost("http://xxx.xxx.xxx.xx/users/createCustomerCardAddress");
    nameValuePairs = new ArrayList<NameValuePair>(11);

    nameValuePairs.add(new BasicNameValuePair("loggedin_id",loggedin_id));
    nameValuePairs.add(new BasicNameValuePair("firstname",fn));
    nameValuePairs.add(new BasicNameValuePair("lastname",ln));
    nameValuePairs.add(new BasicNameValuePair("cardHolderName",cardholdername));
    nameValuePairs.add(new BasicNameValuePair("cardNumber",cardno));
    nameValuePairs.add(new BasicNameValuePair("cardCvv",cvv));
    nameValuePairs.add(new BasicNameValuePair("expDate",expdate));
    nameValuePairs.add(new BasicNameValuePair("address",add));
    nameValuePairs.add(new BasicNameValuePair("state",state));
    nameValuePairs.add(new BasicNameValuePair("city",city));
    nameValuePairs.add(new BasicNameValuePair("pincode",pincode));

    Log.e("----------", "---------");
    for (int i = 0; i < nameValuePairs.size(); i++) {
        Log.e("add / edit new card", nameValuePairs.get(i).getName());
        Log.e("add / edit new card", nameValuePairs.get(i).getValue());
    }
    Log.e("----------", "---------");

    try {
        httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        jsonResponse = httpClient.execute(httpPost, resHandler); // I get org.apache.http.client.HttpResponseException: Not Found 
        Log.e("add edit card response", "-"+jsonResponse);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return jsonResponse;
}

我的日志跟踪:

org.apache.http.client.HttpResponseException: Not Found
at org.apache.http.impl.client.BasicResponseHandler.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:773)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:743)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
at com.fssd.spot.parser.ParsorClass.addNewCardDetail(ParsorClass.java:1098)
at com.fssd.spot.payment.BillingAddress$AddNewcard.doInBackground(BillingAddress.java:146)
at com.fssd.spot.payment.BillingAddress$AddNewcard.doInBackground(BillingAddress.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)

3 个答案:

答案 0 :(得分:3)

给出的Api无效,因此我得到了这个例外。现在我得到了有效的api和工作。感谢。

答案 1 :(得分:0)

请检查服务器端编码...可能是您没有从服务器获得正确的响应。

答案 2 :(得分:0)

此错误导致无效的URL授权。请重新检查HTTP请求,然后再次执行。