How can i call a soap web service that changed from http to https?

99 Views Asked by At

I tried to call a web service that changed recently from HTTP to HTTPS and I get this error :

    java.net.SocketException: Unexpected end of file from server

Note that i had issues with certificates but i added them in the truststore via keytool, then i set System properties with:

    System.setProperty("javax.net.ssl.trustStore", "C://Progra~1//Java//jdk1.8.0_201//jre//lib//security//cacerts");
    System.setProperty("javax.net.ssl.trustStorePassword","changeit");

The error that appears:

main, handling exception: java.net.SocketException: Connection reset main, SEND TLSv1.2 ALERT:  fatal, description = unexpected_message main, WRITE: TLSv1.2 Alert, length = 2 main, 
Exception sending alert: java.net.SocketException: Connection reset by peer: socket write error main, called closeSocket()

thank you in advance for your intervention!

2

There are 2 best solutions below

4
ihimanshu19 On

Adnane, while trying to run the client you can set extra parameter which will print debug logs on ssl connection negotiation with server.

This way you can check if certificate chain is correct and rule out if it is related to certificates.

-Djavax.net.debug=all
0
adnane Lebouiha On

I solved the problème by setting the header as :

Map<String, Object> req_ctx = ((BindingProvider) port).getRequestContext();
    req_ctx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,wsdlURL.toString());          
    Map<String, List<String>> headers = new HashMap<String, List<String>>();
    headers.put("Content-Type", Collections.singletonList("text/xml"));        
    req_ctx.put(MessageContext.HTTP_REQUEST_HEADERS, headers);

the content type was "application/xml".