本文介绍了Android的org.apache.http.client.Htt presponseException:未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用我将用户信息发送到服务器以http如下,我得到的 org.apache.http.client.Htt presponseException:未找到,我有花更多的时间,但能不solution.please帮我找出解决方案。
我在这行得到错误:
jsonResponse = httpClient.execute(httpPost,resHandler);
公共字符串addNewCardDetail(字符串loggedin_id,FN字符串,字符串LN,
字符串cardholdername,字符串cardno,CVV字符串,字符串EXPDATE,字符串添加,
字符串的状态,城市的字符串,字符串针code){ jsonResponse =; HttpClient的=新DefaultHttpClient();
resHandler =新BasicResponseHandler();
httpPost =新HttpPost(HTTP://xxx.xxx.xxx.xx/users/createCustomerCardAddress);
namevaluepairs中=新的ArrayList<&的NameValuePair GT;(11); nameValuePairs.add(新BasicNameValuePair(loggedin_id,loggedin_id));
nameValuePairs.add(新BasicNameValuePair(名字,FN));
nameValuePairs.add(新BasicNameValuePair(姓氏,LN));
nameValuePairs.add(新BasicNameValuePair(cardHolderName,cardholdername));
nameValuePairs.add(新BasicNameValuePair(cardNumber,cardno));
nameValuePairs.add(新BasicNameValuePair(cardCvvCVV));
nameValuePairs.add(新BasicNameValuePair(EXPDATE,EXPDATE));
nameValuePairs.add(新BasicNameValuePair(地址,加));
nameValuePairs.add(新BasicNameValuePair(国家,状态));
nameValuePairs.add(新BasicNameValuePair(城市,市));
nameValuePairs.add(新BasicNameValuePair(销code,针code)); Log.e(----------,---------);
的for(int i = 0; I< nameValuePairs.size();我++){
Log.e(添加/编辑新卡,nameValuePairs.get(I).getName());
Log.e(添加/编辑新卡,nameValuePairs.get(I).getValue());
}
Log.e(----------,---------); 尝试{
httpPost.setEntity(新UrlEn codedFormEntity(namevaluepairs中));
jsonResponse = httpClient.execute(httpPost,resHandler); //我得到org.apache.http.client.Htt presponseException:未找到
Log.e(添加编辑卡响应, - + jsonResponse);
}赶上(UnsupportedEncodingException五){
e.printStackTrace();
}赶上(ClientProtocolException E){
e.printStackTrace();
}赶上(IOException异常五){
e.printStackTrace();
}
返回jsonResponse;
}
我的日志跟踪:
org.apache.http.client.Htt presponseException:未找到
在org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:71)
在org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:59)
在org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:773)
在org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:743)
在org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
在com.fssd.spot.parser.ParsorClass.addNewCardDetail(ParsorClass.java:1098)
在com.fssd.spot.payment.BillingAddress $ AddNewcard.doInBackground(BillingAddress.java:146)
在com.fssd.spot.payment.BillingAddress $ AddNewcard.doInBackground(BillingAddress.java:1)
在android.os.AsyncTask $ 2.call(AsyncTask.java:287)
在java.util.concurrent.FutureTask中$ Sync.innerRun(FutureTask.java:305)
在java.util.concurrent.FutureTask.run(FutureTask.java:137)
在android.os.AsyncTask $ SerialExecutor $ 1.run(AsyncTask.java:230)
在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
在java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:569)
在java.lang.Thread.run(Thread.java:856)
解决方案
给出的API是无效的,这样我得到这个例外。现在我得到有效的API和工作。谢谢你。
In my app I send user information to server with http as follows, I get org.apache.http.client.HttpResponseException: Not Found and I have spend more time but could not solution.please help me find out the solution.
I get error at this line:
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;
}
My Log trace:
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)
解决方案
The Api given is invalid so that I get this exception. now I get valid api and working. Thanks.
这篇关于Android的org.apache.http.client.Htt presponseException:未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!