由网友(牵xx的手鸭)分享简介:需要使用HTTPS协议,从服务供应商的响应将是一个XML文件,发送POST请求到服务提供商,需要读也。Need to send a POST request to a Service provider using HTTPS protocol, response from the service provider w...
需要使用HTTPS协议,从服务供应商的响应将是一个XML文件,发送POST请求到服务提供商,需要读也。
Need to send a POST request to a Service provider using HTTPS protocol, response from the service provider will be an xml file, need to read that also.
推荐答案
您可以通过采取一看的 AndroidHttpClient 和的 HttpPost 。
You could start by taking a look at AndroidHttpClient and at HttpPost.
像这样的应的工作:
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);
}
}
另外,我的 RESTClient实现在github上可能是有用的。注:我使用GET检索数据,所以因人而异
Also, my RestClient on github might be useful. Note: I use GET to retrieve the data, so YMMV.
相关推荐
最新文章