我需要知道如何通过POST
连接到HTTPS
web服务。我看了一下tutorial,但它太旧了,所以没有用。
有没有人可以通过给我一个好的教程或者一些示例代码来帮助我呢?
发布于 2012-06-01 01:43:07
试试apache HttpClient库。它支持https。
发布于 2012-06-01 01:49:52
如下所示:
URL url = new URL("https://...");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod("POST");
//write the request body
OutputStream requestBody = connection.getOutputStream();
...
requestBody.flush();
//send the request and get the response body
InputStream responseBody = connection.getInputStream();
...
https://stackoverflow.com/questions/10838363
复制相似问题