1

Before loading WSDL from https URL for my dynamic client I need to set appropriate configuration on HttpConduit to avoid all SSL errors. According to docs we could hardcode conduit but not sure to do it programmatically. Is there way I could get hold of HttpConduit before creating Client object on DynamicClientFactory?

JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();

//Need to get HttpConduit here before the client is created, how?
Client client = dcf.createClient(wsdlUri);

// Can access http conduit only after client is created
HTTPConduit conduit = (HTTPConduit) client.getConduit();
Stackee007
  • 3,196
  • 1
  • 26
  • 39

1 Answers1

1

One way to get of hold HttpConduit and customize the http(s) configuration is through HTTPConduitConfigurer. Below code snippet shows how it can be done.

Bus bus = CXFBusFactory.getThreadDefaultBus();
bus.setExtension(new HTTPConduitConfigurer() {

    @Override
    public void configure(String name, String address, HTTPConduit conduit) {
        //set conduit parameters ...

        // ex. disable host name verification
        TLSClientParameters clientParameters = new TLSClientParameters();
        clientParameters.setHostnameVerifier(new HostnameVerifier() {
            @Override
            public boolean verify(String hostname, SSLSession session) {
                return true;
            }
        });
        conduit.setTlsClientParameters(clientParameters);
    }
}, HTTPConduitConfigurer.class);

JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(bus);
Client client = dcf.createClient(wsdlUri);
Stackee007
  • 3,196
  • 1
  • 26
  • 39