HttpClient request an instance of https:
Import Javax.net.ssl.SSLContext;
Import Javax.net.ssl.TrustManager;
Import Javax.net.ssl.X509TrustManager;
Import java.security.cert.CertificateException;
Import Java.security.cert.X509Certificate;
Import org.apache.http.client.ClientProtocolException;
Import org.apache.http.client.HttpClient;
Import Org.apache.http.client.ResponseHandler;
Import Org.apache.http.client.methods.HttpGet;
Import Org.apache.http.conn.ClientConnectionManager;
Import Org.apache.http.conn.scheme.Scheme;
Import Org.apache.http.conn.scheme.SchemeRegistry;
Import Org.apache.http.conn.scheme.SchemeSocketFactory;
Import Org.apache.http.conn.ssl.SSLSocketFactory;
Import Org.apache.http.impl.client.BasicResponseHandler;
Import Org.apache.http.impl.client.ClientParamsStack;
Import org.apache.http.impl.client.DefaultHttpClient;
Import Org.apache.http.params.DefaultedHttpParams;
Import Org.apache.http.params.HttpParams; public class Httpclienttest {public static void main (String args[]) {try {httpclientHttpClient = new Defaulthttpclient ();
Secure Protocol implementation.
Sslcontext CTX = sslcontext.getinstance ("SSL"); Implementation of a trust manager for X509 certificates X509trustmanager TM = new X509trustmanager () {public VO ID checkclienttrusted (x509certificate[] Xcs, string string) throws Certificateexception {} public void ch Eckservertrusted (x509certificate[] Xcs, string string) throws Certificateexception {} public X509certifica
Te[] Getacceptedissuers () {return null;
}
};
Ctx.init (NULL, new trustmanager[] {TM}, NULL);
Sslsocketfactory SSF = new Sslsocketfactory (CTX);
Clientconnectionmanager CCM = Httpclient.getconnectionmanager ();
Register HTTPS protocol in HttpClient ' s scheme registry Schemeregistry sr = Ccm.getschemeregistry ();
Sr.register (New Scheme ("https", 443, SSF));
HttpGet httpget = new HttpGet (""); Httpparams PArams = Httpclient.getparams ();
Params.setparameter ("param1", "paramValue1");
Httpget.setparams (params);
System.out.println ("REQUEST:" + Httpget.geturi ());
ResponseHandler ResponseHandler = new Basicresponsehandler ();
String responsebody;
Responsebody = Httpclient.execute (HttpGet, ResponseHandler);
System.out.println (responsebody); Create a response handler} catch (NoSuchAlgorithmException e) {//TODO auto-generated catch block E.printsta
Cktrace ();
catch (Clientprotocolexception e) {//TODO auto-generated catch block E.printstacktrace ();
catch (IOException e) {//TODO auto-generated catch block E.printstacktrace ();
catch (Exception ex) {ex.printstacktrace ();
}
}
}