1

我需要知道如何POST使用HTTPS网络服务。我浏览了教程,但它没有帮助,因为它太旧了。

任何人都可以通过给我一个很好的教程或一些示例代码来帮助我吗?

4

2 回答 2

2

试试 apache HttpClient库。它支持https

于 2012-05-31T17:43:07.237 回答
0

像这样的东西:

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();
...
于 2012-05-31T17:49:52.313 回答