Hi,

As you already have port(the proxy)  pool, which means there won't be multiple 
thread access same proxy at the same time, you actually needn't set 
thread.local.request.context.

If there's only one proxy, you need set thread.local.request.context, using 
code like
((BindingProvider)port).getRequestContext().put("thread.local.request.context", 
"true");
to make it thread safe
-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: @Freeman小屋

www.camelone.org : The open source integration conference: 

On 2013-5-22, at 上午4:31, Warren, Jared S wrote:

> 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.
> 

Reply via email to