My environment is a Maven Project and Wildfly (8.2.1) as Application Server. What I need is to connect wihin a incoming REST call to a third party server using SOAP. I need SSL Client Authentication; therefore, I have my own KeyStore and TrustStore. I create therefore my own SSLContext and need to let the WebService use this SSLContext.
There is a problem with Wildfly and it's used implementation of JAXWS (Apache CXF?) - I described it here (but with another aproach to solve the problem; therefore it is not a duplicate post!):
Wildfly: How to use JAXWS-RI instead of Apache CXF (WebService client only)
One of the main problems seems to be that JAXWS used in Wildfly seems to ignore setting the own SSLContext with property
MyWS_Service service = new MyWS_Service(null, new QName("http://...", "MyWS"));
MyWS port = service.getMyWSSOAP();
BindingProvider bindingProvider = (BindingProvider) port;
// the following setting is ignored!
// in some posts, we see that we need to eliminate 'internal' in the property. This does not help!
The problem is definitifely that Apache CXF ignores
bindingProvider.getRequestContext().put( "com.sun.xml.[internal.]ws.transport.https.client.SSLSocketFactory", mySslSocketFactory);
in oposite to some comments some where.
So my final solution is to programmatically setup the
HTTPConduit used (rather than set a config in a
// Set custom SSLContext. HTTPConduit conduit = (HTTPConduit) ClientProxy.getClient(port).getConduit(); TLSClientParameters tlsClientParameters = new TLSClientParameters(); tlsClientParameters.setSSLSocketFactory(customSSLContext.getSocketFactory()); conduit.setTlsClientParameters(tlsClientParameters);
I hope that this helps some one having similar issues...