I'm connecting to many web services with the same WSDL definition at different locations, where each of them has different untrusted CAs, that can be changed at any time. For this, I created a SSLSocketFactory that contains the right CA depending on where I connect to, and a SSL client certificate.
The problem is, that the only way I'm able to do it is to set the default ssl factory using HttpsURLConnection.setDefaultSSLSocketFactory(sslfactory). But I need to synchronize on global object to prevent simultaneous connections to overwrite each others factory. Secondly, in future we want to deploy another application to the same application server, which could not synchronize.
I tried to set the JAXWSProperties.SSL_SOCKET_FACTORY to the RequestContext, but it is only available after calling the MyService constructor, which already connects to get the wsdl file.
Is there any way to set the ssl factory just for a particular connection?