ore*_*ion 3 android http-request
我有一个抛出null异常的HTTP请求.
这是代码:
public String updateRounds() {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("https://technet.rapaport.com/HTTP/Prices/CSV2_Round.aspx");
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("Username", _user));
nameValuePairs.add(new BasicNameValuePair("Password", _password));
try {
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String response = "";
// Execute HTTP Post Request
try {
response = httpclient.execute(httppost, responseHandler); // it gets
// exception
// here
} catch (Exception e) {
e.getMessage(); // e is null
}
return response;
}
Run Code Online (Sandbox Code Playgroud)
任何人都知道为什么会这样吗?
谢谢大家的帮助.我改变了
e.getMessage();
Run Code Online (Sandbox Code Playgroud)
至
e.printStackTrace();
Run Code Online (Sandbox Code Playgroud)
我看到异常是关于ssl证书.所以我处理了它,现在它可以工作了.谢谢你们.
| 归档时间: |
|
| 查看次数: |
4838 次 |
| 最近记录: |