Recently a friend of financial companies do financial Alipay Alipay But I did not move to the end of the interface, I think I can simulate HTTPS submit data to the server, but I treasure the financial HTTPS to HTTP Jiaoshu someone not familiar with this area it can be done with each other Learning under HTTPS is not what you want to download, ah KEY
Reply:
I QQ940378589 can learn from each other under
Reply:
Use httpClient it supports.
private static volatile HttpClient HTTP_CLIENT;
private static Object HTTP_CLIENT_LOCK = new Object ();
private static int CONNECT_TIMEOUT_IN_MS = 30 * 1000;
private static int SOCKET_TIMEOUT_IN_MS = 30 * 1000;
private static HttpClient getHttpClient () {
if (HTTP_CLIENT == null) {
synchronized (HTTP_CLIENT_LOCK) {
if (HTTP_CLIENT == null) {
HttpParams params = new BasicHttpParams ();
HttpConnectionParams.setConnectionTimeout (params, CONNECT_TIMEOUT_IN_MS);
HttpConnectionParams.setSoTimeout (params, SOCKET_TIMEOUT_IN_MS);
ConnManagerParams.setMaxTotalConnections (params, 100);
HttpProtocolParams.setVersion (params, HttpVersion.HTTP_1_1);
SchemeRegistry schemeRegistry = new SchemeRegistry ();
schemeRegistry.register (new Scheme ("http", PlainSocketFactory.getSocketFactory (), 80));
schemeRegistry.register (new Scheme ("https", SSLSocketFactory.getSocketFactory (), 443));
ClientConnectionManager cm = new ThreadSafeClientConnManager (params, schemeRegistry);
HTTP_CLIENT = new DefaultHttpClient (cm, params);
}
}
}
return HTTP_CLIENT;
}
protected HttpUriRequest createHttpRequest (Mapparam) {
Uri.Builder builder;
Uri pathUri = Uri.parse ("https://www.xxx.x/xxxx");
builder = pathUri.buildUpon ();
for (String key: param.keySet ()) {
builder.appendQueryParameter (key, param.get (key));
}
return new HttpGet (builder.toString ());
}
/ / Use the sample:
HttpClient client = getHttpClient ();
HttpResponse resp = client.execute (createHttpRequest (Map));
HttpEntity entity = resp.getEntity ();
StatusLine statusLine = resp.getStatusLine ();
No comments:
Post a Comment