cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "smirnov.kirill" <>
Subject How can I make requests with dynamic headers?
Date Wed, 05 Nov 2014 17:23:14 GMT
I have already asked this question on StackOverflow, but nobody has answered

I want to make a Java-based SOAP client, which connects to the server which
uses CXF. I have services' interfaces (jar from the Server) and classes
which wrap requests/responses to the server. So I tried to use CXF on the
client side too.

So what I do now is

1) get instance for the service's interface

JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
List<Interceptor&lt;? extends Message>> outInterceptors = new
ArrayList<Interceptor&lt;? extends Message>>();
List<Interceptor&lt;? extends Message>> inInterceptors = new
ArrayList<Interceptor&lt;? extends Message>>();
outInterceptors.add(new OutInterceptor(login, password));
inInterceptors.add(new InInterceptor());
factory.setAddress(currentEndpoint + "/oxygen");
oxygenService = (OxygenService)factory.create();

2) So now I have an instance of the service - oxygenService. And so I can
perform requests. Like this:

oxygenService.updateProfile(userId, lastName, firstName, phone);
Unfortunately, there is a huge problem - how can I specify extra dynamic
headers for each request? The server expects from me special header called
'dynamicId'. I can calculate it's value while calling oxygenService, but it
seems there is no way to specify headers there - all I can is to call
something from oxygenService. The only way to specify header is to use
interceptors, but I can not get 'dynamicId' in the interceptor (because how
can I know which 'dynamicId' is related to which request).

So to sum up, there is a list of what I want:

1) I want to keep using services' interfaces
2) I want to keep using request and response wrappers (not to generate xml
3) I want to dynamically specify headers for exact request
4) Solution has to be thread-safe

I also figured out that there is ClientProxy which can change headers for
oxygenService, but it's not safe in terms of concurrency.

View this message in context:
Sent from the cxf-user mailing list archive at

View raw message