mercredi 17 mai 2017

I am getting below exception at “DataOutputStream wr = new DataOutputStream(con.getOutputStream());” this statement. “javax.net.ssl.SSLException

I am getting below exception at DataOutputStream wr = new DataOutputStream(con.getOutputStream());

This statement:

javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

Below is the code:

HttpURLConnection con; String inputLine; StringBuffer response=null;

try{ URL obj = new URL(null, url, new
sun.net.www.protocol.https.Handler()); con = (HttpURLConnection)
obj.openConnection(); //(HttpsURLConnection)
con.setRequestMethod(“POST”);
con.addRequestProperty(“Content-Type”,”application/json”);

for(Map.Entry prop : header.entrySet()) {
con.setRequestProperty(prop.getKey(),prop.getValue()); }

con.setDoOutput(true); DataOutputStream wr = new
DataOutputStream(con.getOutputStream());
wr.writeBytes(postParameters); wr.flush(); wr.close();

Aucun commentaire:

Enregistrer un commentaire