String keystore = "certs"+File.separator+"truststore.jks";
File keyStoreFile = new File (keystore);
if(keyStoreFile.exists()){
System.out.println("KeyStore file exists :abs path = "+ keyStoreFile.getAbsolutePath());
}else{
System.out.println("KeyStore file does not exist :abs path = "+ keyStoreFile.getAbsolutePath());
}
try {
// System.setProperty("javax.net.debug", "ssl,handshake,data,trustmanager");
System.setProperty("javax.net.ssl.trustStoreType", "HDImageStore");
System.setProperty("javax.net.ssl.trustStore",keystore);
System.setProperty("javax.net.ssl.trustStorePassword", "019876");
final String urlName = "
https://TIMTESTER.PRIME-TASS.LOCAL/RA/RA.wsdl";
final URL url = new URL(urlName);
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.connect();
//вывод полей заголовка
int n = 1;
String key;
while ((key = connection.getHeaderFieldKey(n)) != null)
{
String value = connection.getHeaderField(n);
System.out.println(key + ": " + value);
n++;
}
//вывод данных вместе с названием функции
System.out.println("-----------------");
System.out.println("getContentType: " + connection.getContentType());
System.out.println("getContentLength: " + connection.getContentLength());
System.out.println("getContentEncoding: " + connection.getContentEncoding());
System.out.println("getDate: " + connection.getDate());
System.out.println("getExpiration: " + connection.getExpiration());
System.out.println("getLastModified: " + connection.getLastModified());
System.out.println("------------------");
System.out.println("getHeaderFields:\n" + connection.getHeaderFields());
System.out.println("------------------");
final BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
//вывод полученных данных в файл
String line;
String text = "";
n = 1;
while ((line = in.readLine()) != null) {
text = text + line;
n++;
}
final byte[] data = text.getBytes();/**/
final FileOutputStream fout =new FileOutputStream("url.html");
try {
fout.write(data);
} finally {
if (fout != null)
fout.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}