I can't answer your question about adding a HTTP header to the automatic call to load the WSDL (I don't believe it would be possible... but not sure), but I gave up trying to initialise my clients via a remote WSDL long ago. It can cause all sorts of problems if systems are offline, or still starting at the wrong time, etc. I always aim to:
1. store the WSDL locally in the app and load it from the classpath (you could also just store it locally on the filesystem and use a file:/ URL) - after all, it's usually a contract that *probably won't* change without code changes at your end as well 2. initialise the client using the local WSDL so that you know your app will always start correctly 3. configure the endpoint address of the service manually rather than rely on what's in the WSDL (I usually just make the WSDL service URLs http://localhost) URL wsdl = myConfig.getWSDL(); > MyService service = new MyService(wsdl); > MyPort port = service.getMyPort(); If you are using Spring Boot then you can use a @ConfigurationProperties class for myConfig with a URL property, specifying "classpath:/path/to/MyService.wsdl" in the application.yml file. Here is how you manually initialise the endpoint address: BindingProvider bp = (BindingProvider) port; > bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, > myConfig.getEndpointAddress()); And here is a sample of how to add HTTP headers for the outbound calls to your service: var client = ClientProxy.getClient(port); > var headerInterceptor = new HttpHeaderInterceptor(); > client.getOutInterceptors().add(headerInterceptor); var headers = headerInterceptor.getHeaders(); headers.put("name", Arrays.asList("value")); I hope that helps in the long run. On Mon, 23 Jan 2023 at 23:17, Ege, Bernhard <bernhard....@cgm.com> wrote: > Hi, > > I am trying to add a HTTP(S) request header when I am creating my SOAP > client (from autogenerated code by wsdl2java). > > The client is created easily enough: > > SSNLookupService ssnLookupService = new SSNLookupService(ssnUrl); > ssnLookupServiceClient = > ssnLookupService.getBasicHttpBindingISSNLookupService(); > > Problem is, during these two lines, a request is sent to get the WSDL, but > for that WSDL to be returned, I need to add a custom HTTP header. > > I have not been able to find the path to do this. > > I expect I have to interact with ssnLookupService (SSNLookupService > extends javax.xml.ws.Service) but having search for a while, I can find no > examples on how to do this. > > I ask here as I think this could be CXF specific, but I honestly don't > know. > > Thank you, > > /Bernhard > >