I need to include a unique value in an http header field for each request from
my CXF client to the web service provider.
It's my understanding that I can do this when I initialize a port:
ServiceControllerAdapter svc =
adapter.getServiceControllerAdapter();
Client client = ClientProxy.getClient(svc);
client.getRequestContext().put("thread.local.request.context",
"true");
Then I can use an object pool to pool the adapters, and do something like this
each time I need one with unique headers:
ServiceControllerAdapter port = (ServiceControllerAdapter)
portPool.borrowObject();
Map<String, List<String>> headers = new HashMap<String,
List<String>>();
List<String> mdcIdList = new LinkedList<String>();
String mdcId = this.getUniqueId();
mdcIdList.add(mdcId);
headers.put("MDCID", mdcIdList);
Client client = ClientProxy.getClient(port);
client.getRequestContext().put(org.apache.cxf.message.Message.PROTOCOL_HEADERS,
headers);
response = port.process(request);
client.getRequestContext().put(org.apache.cxf.message.Message.PROTOCOL_HEADERS,
Collections.EMPTY_MAP);
portPool.returnObject(port);
(Note: for reasons beyond the scope of this note, I'm stuck on Apache CXF
2.2.10.)
Can anyone validate that this should work?
Thanks!
jared
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. If the reader of this message is not the intended recipient,
you are hereby notified that your access is unauthorized, and any review,
dissemination, distribution or copying of this message including any
attachments is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete the material from any
computer.