JAXWS Socket Factory setting does not work

30 views Asked by At

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);
1

There are 1 answers

0
dschulten On

The constant SSL_SOCKET_FACTORY has a different value depending on the JAXWS implementation in use. The one in JDK 8 is in the class com.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 JAXWSProperties which has the SSL_SOCKET_FACTORY constant that matches your runtime.

FYI, the actual Strings are:

  • JDK 8: "com.sun.xml.internal.ws.transport.https.client.SSLSocketFactory"
  • JAXWS-RI: "com.sun.xml.ws.transport.https.client.SSLSocketFactory"

However, do not use them verbatim, rather pick the correct JAXWSProperties class.