Sure, this is what JAXRSOutInterceptor does :
MessageContentsList objs = MessageContentsList.getContentsList(message);
if (objs == null || objs.size() == 0) {
return;
}
if (objs.get(0) != null) {
// this is what a given JAXRS method has returned : JAXRS Response,
Book, Feed, etc
Object responseObj = objs.get(0);
// convert to JAXRS Response if needed
Response response = null;
if (objs.get(0) instanceof Response) {
response = (Response)responseObj;
} else {
int status = getStatus(message, 200);
response = Response.status(status).entity(responseObj).build();
}
}
Next, JAXRSOutInterceptor will let filters, if any, react to this
Response, and override it if needed.
So if you'd like to check the response entity in the CXF interceptor
instead and say you know that your service does not return explicit
JAXRS responses then you can probably do :
MessageContentsList objs = MessageContentsList.getContentsList(message);
Object responseObj = objs.get(0)
// set etag on the Message.PROTOCOL_HEADERS
or just build a custom Response directly in this interceptor, using
JAXRS Response/ResponseBuilder api and set it on the message such that
JAXRSOutInterceptor can pick it up, you can do it like this :
Response response =
Response.ok().etag(etagValue).entity(responseObj).build();
outMessage.setContent(List.class, new MessageContentsList(response));
Hope it helps, Sergey
-----Original Message-----
From: Paul Wilton [mailto:[email protected]]
Sent: 30 December 2009 11:26
To: [email protected]
Cc: Sergey Beryozkin
Subject: RE: Message.RESPONSE_HEADERS does not exist as documented in
CCXF 2.2.5
Cool - thanks
Is it possible to get hold of the JAXRS Response object in an impl of a
AbstractOutDatabindingInterceptor
In order to generate an etag from the response entity (not the http
response object, but the JAXRS Response) ?
-----Original Message-----
From: Sergey Beryozkin [mailto:[email protected]]
Sent: 30 December 2009 11:00
To: [email protected]
Subject: RE: Message.RESPONSE_HEADERS does not exist as documented in
CCXF 2.2.5
Hi
Sorry about it, I fixed it, should be Message.PROTOCOL_HEADERS
Cheers, Sergey
-----Original Message-----
From: Paul Wilton [mailto:[email protected]]
Sent: 30 December 2009 10:39
To: [email protected]
Subject: Message.RESPONSE_HEADERS does not exist as documented in CCXF
2.2.5
Hi
In the documentation here is describes how to add a custom out
databinding interceptor to modify the response headers (eg to add an
ETag):
http://cwiki.apache.org/CXF20DOC/jax-rs.html#JAX-RS-Overridingresponsest
atuscodeandheaders
However the String Message.RESPONSE_HEADERS does not exist in the
org.apache.cxf.message.Message class in cxf 2.2.5
What should we be using instead to get the headers -
Message.PROTOCOL_HEADERS ?
Thanks
Paul
This e-mail (and any attachments) is confidential and may contain
personal views which are not the views of the BBC unless specifically
stated. If you have received it in error, please delete it from your
system. Do not use, copy or disclose the information in any way nor act
in reliance on it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received. Further
communication will signify your consent to this
This e-mail has been sent by one of the following wholly-owned
subsidiaries of the BBC:
BBC Worldwide Limited, Registration Number: 1420028 England, Registered
Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
BBC World News Limited, Registration Number: 04514407 England,
Registered Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
BBC World Distribution Limited, Registration Number: 04514408,
Registered Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ