If you find this blog helpful or useful then you can donate by clicking ads on this website.

In order to get response through SSL from axis2 webservice you need to open streams like given below.

URLConnection conn = url.openConnection();
 if (conn instanceof HttpsURLConnection) {
 ((HttpsURLConnection) conn).setSSLSocketFactory(sslSocketFactory);
 ((HttpsURLConnection) conn).setRequestMethod(POST);
 }

conn.setAllowUserInteraction(true);
 conn.setRequestProperty(CONTENT_TYPE, CONTENT_TYPE_VALUE);
 conn.setRequestProperty(SOAP_ACTION, soapAction);
 conn.setDoOutput(true);

out = new OutputStreamWriter(conn.getOutputStream());

ByteArrayOutputStream baos = new ByteArrayOutputStream();
 soapMessage.writeTo(baos);
 String msg = baos.toString();

out.write(msg);
 out.flush();
 if (out != null) {
 out.close();
 }

String line = "";
 in = new BufferedReader(new InputStreamReader(conn.getInputStream()));

while ((line = in.readLine()) != null) {
 response = response + line;
 }
 if (in != null) {
 in.close();
 }

System.out.println("response : " + response);

-------------------
 sslSocketFactory can be created from this code.

Tags: , ,

Leave a Reply