You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Canning, Charles" <cc...@stubhub.com> on 2015/07/16 03:23:59 UTC

Header propagation between chained REST calls

Hi,

Problem:

I want to be able to pass a custom header from external client into a REST container call and propagate it with all client REST requests from the container.

Browser  —> RestEndpoint  —> Another RestEndpoint.


I am going through the JAX-RS 2 specification and there are ContainerRequestFilters and ClientRequestFilters and corresponding xxxContext objects but can’t seem to find a shared context. Does CXF have a shared context to allow this or do I have to look into something like ThreadLocal? Or is there a better approach available with CXF?

Thanks,
chuck

Re: Header propagation between chained REST calls

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 16/07/15 04:23, Canning, Charles wrote:
> Hi,
>
> Problem:
>
> I want to be able to pass a custom header from external client into a REST container call and propagate it with all client REST requests from the container.
>
> Browser  —> RestEndpoint  —> Another RestEndpoint.
>
>
> I am going through the JAX-RS 2 specification and there are ContainerRequestFilters and ClientRequestFilters and corresponding xxxContext objects but can’t seem to find a shared context. Does CXF have a shared context to allow this or do I have to look into something like ThreadLocal? Or is there a better approach available with CXF?
>
have
@Context HttpHeaders httpHeaders;
and call:
https://jax-rs-spec.java.net/nonav/2.0-rev-a/apidocs/javax/ws/rs/core/HttpHeaders.html#getRequestHeaders%28%29

Next pass this map to
https://jax-rs-spec.java.net/nonav/2.0-rev-a/apidocs/javax/ws/rs/client/Invocation.Builder.html#headers(javax.ws.rs.core.MultivaluedMap)

This builder is returned when one of WebTarget's request() methods is 
called...

Cheers, Sergey
> Thanks,
> chuck
>