I'm trying to connect to a web service that uses the client/server mutual connection, it throws me a NoSuchAlgorithmException, when i run the same code as an standard java application it works great but when i try to run as a web application i get the exception, any idea to solve this issue?
The Code:
try {
System.setProperty("javax.net.debug", "ssl,handshake");
System.setProperty("javax.net.ssl.keyStoreType", "pkcs12");
System.setProperty("javax.net.ssl.keyStore", "c:\\Sifen\\F1T_5159.p12");
System.setProperty("javax.net.ssl.keyStorePassword", "password");
String soapRequest = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:xsd=\"http://ekuatia.set.gov.py/sifen/xsd\">\n"
+ "<soap:Header/>\n"
+ "<soap:Body>\n"
+ "<xsd:rEnviConsRUC xmlns=\"http://ekuatia.set.gov.py/sifen/xsd\"\n"
+ " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
+ " xsi:schemaLocation=\"http://ekuatia.set.gov.py/sifen/xsd/ siConsRUC_v150.xsd\">\n"
+ " <xsd:dId>1</xsd:dId>\n"
+ " <xsd:dRUCCons>80033703</xsd:dRUCCons>\n"
+ "</xsd:rEnviConsRUC>\n"
+ "</soap:Body>\n"
+ "</soap:Envelope>";
String url = "https://sifen-test.set.gov.py/de/ws/consultas/consulta-ruc.wsdl";
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
con.setDoOutput(true);
try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) {
wr.writeBytes(soapRequest);
wr.flush();
}
String responseStatus = con.getResponseMessage();
System.out.println(responseStatus);
BufferedReader in = new BufferedReader(new InputStreamReader(
con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
String finalvalue = response.toString();
System.out.println(finalvalue);
} catch (Exception e) {
System.out.println(e.getMessage());
}
The Result java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
Again: when i run it as a java standard aplication works fine, i only get the exception if i run as a web application
Any ideas? Please help, thanks.
in a standard java application? Pls describe more specifically how you invoke it on these two approaches