I am calling a SOAP Webservice with JAXWS, but the SSL Socket Factory does not work. Instead of using my trust- and keystore, the application uses the default truststore of the JRE.
BindingProvider bindingProvider = (BindingProvider) myWebservicePort;
Map<String, Object> requestContext = bindingProvider.getRequestContext();
requestContext.put(JAXWSProperties.SSL_SOCKET_FACTORY, sslSocketFactory);
The constant
SSL_SOCKET_FACTORYhas a different value depending on the JAXWS implementation in use. The one in JDK 8 is in the classcom.sun.xml.internal.ws.developer.JAXWSProperties, whereas the reference implementation JAXWS-RI (provided e.g. by JakartaEE or other sources before JakartaEE took over from Oracle) has the same class in a different package:com.sun.xml.ws.developer.JAXWSProperties.So make sure you import the version of
JAXWSPropertieswhich has theSSL_SOCKET_FACTORYconstant that matches your runtime.FYI, the actual Strings are:
"com.sun.xml.internal.ws.transport.https.client.SSLSocketFactory""com.sun.xml.ws.transport.https.client.SSLSocketFactory"However, do not use them verbatim, rather pick the correct
JAXWSPropertiesclass.