开发者

HTTPS request/response in Android

Need to send a POST request to开发者_Python百科 a Service provider using HTTPS protocol, response from the service provider will be an xml file, need to read that also.


You could start by taking a look at AndroidHttpClient and at HttpPost.

Something like this should work:

 final AndroidHttpClient httpClient = AndroidHttpClient.newInstance(this.getClass().getSimpleName());
 HttpResponse httpresponse   = null;
 HttpEntity httpentity       = null;
 HttpUriRequest httprequest = new HttpPost("https://...");
 byte[] xmlByteArray = null;

 if ((httpresponse = httpClient.execute(httprequest)) != null) {
  if ((httpentity = httpresponse.getEntity()) != null) {
   xmlByteArray = EntityUtils.toByteArray(httpentity);
  }
 }

Also, my RestClient on github might be useful. Note: I use GET to retrieve the data, so YMMV.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜