In JAXRS & JAXWS case a CXF out interceptor would need to modify the
headers directly on the outbound message, don't remember at the moment
the property key, check please Message class if needed..., in JAXRS only
dealing with Response would do

Cheers, Sergey



-----Original Message-----
From: Sergey Beryozkin [mailto:[email protected]] 
Sent: 17 June 2009 21:12
To: [email protected]
Subject: RE: Best way to append logic to response header

Hi

One way is to register a ResponseHandler JAX-RS filter :
http://cwiki.apache.org/CXF20DOC/jax-rs.html#JAX-RS-Filters

You can substitute a Response to be serialized with your own one, for
ex, you can create a new one and copy the provided one into it and then
add few headers or update  the entity as needed.

A similar option is to register a CXF out interceptor at the stage
UNMARSHAL, you can get a Response from a message like this :

Response r = message.getExchange().get(Response.class);

create a new one and reset it on the exchange. This would work for
JAXRS&JAXWS

hope it helps, Sergey  

-----Original Message-----
From: mieke [mailto:[email protected]] 
Sent: 17 June 2009 20:11
To: [email protected]
Subject: Best way to append logic to response header


Set up - CXF, Spring, JAX-RS

I have some RESTfull services that return various data formats (xml,
json). 
I would like to add some additional data to the response header.  What
is
the best approach to doing this?

String context file has the following ...
<jaxrs:server id="servicesREST" address="/rest">
  <jaxrs:serviceBeans>
    <ref bean="servicesSEI" />
  </jaxrs:serviceBeans>
</jaxrs:server>

My test method in the impl

    @GET
    @Produces("application/xml")
    @Path("/upper/{string}")
    public String toUpper(@PathParam("string") String string) {
        return "<test>" + string.toUpperCase() + "</test>" ;

    }


Appreciate your help.

Thanks,

Mieke



-- 
View this message in context:
http://www.nabble.com/Best-way-to-append-logic-to-response-header-tp2408
0075p24080075.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to