You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by bird bird <bi...@googlemail.com> on 2011/08/22 20:22:45 UTC
cxfrs response headers
Hi all.
How do I set response headers when implementing REST using the CXFRS
component. I am new and learning camel by developing a small bundle for my
own use. I have developed services which return XML (from the exchange
body) when the requests cannot be serviced I use the class
javax.ws.rs.core.Response to return a status code. All working, followed
example as http://camel.apache.org/cxfrs.html.
Using the Response / ResponseBuilder classes I can set headers in the http
response when in error, but my question is how do I do this when returning
a successful payload. i.e status 200 with the XML in the body i.e.
exchange.getOut().setBody(bookResource). Following the principles of REST
it is quite common to set the response Location: and Content-Location:
headers in the URL of the resource.
Any ideas - loving camel/EIP,
Rango.
Re: cxfrs response headers
Posted by rangob <bi...@googlemail.com>.
Lovely. Thank you Willem.
--
View this message in context: http://camel.465427.n5.nabble.com/cxfrs-response-headers-tp4725138p4726311.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: cxfrs response headers
Posted by Willem Jiang <wi...@gmail.com>.
Hi
With the help of Reponse/ ResponseBuilder, you can build the response
for the bookResource like this
Response r =
Response.status(200).entity(bookResource).header(xxx,xxx).build();
exchange.getOut().setBody(r);
On 8/23/11 2:22 AM, bird bird wrote:
> Hi all.
>
> How do I set response headers when implementing REST using the CXFRS
> component. I am new and learning camel by developing a small bundle for my
> own use. I have developed services which return XML (from the exchange
> body) when the requests cannot be serviced I use the class
> javax.ws.rs.core.Response to return a status code. All working, followed
> example as http://camel.apache.org/cxfrs.html.
>
> Using the Response / ResponseBuilder classes I can set headers in the http
> response when in error, but my question is how do I do this when returning
> a successful payload. i.e status 200 with the XML in the body i.e.
> exchange.getOut().setBody(bookResource). Following the principles of REST
> it is quite common to set the response Location: and Content-Location:
> headers in the URL of the resource.
>
> Any ideas - loving camel/EIP,
>
> Rango.
>
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang