Hi
On 07/08/12 14:02, jpcook01 wrote:
Hi,
I had the following custom response handler for logging http error codes:
public class HttpErrorResponseLogger implements ResponseHandler {
private Logger log = Logger.getLogger("HttpErrorResponseLogger");
@Override
public Response handleResponse(Message message, OperationResourceInfo
info,
Response response) {
int status = response.getStatus();
if(status> 399&& status< 600) {
Object method =
message.get(Message.HTTP_REQUEST_METHOD);
Object url = message.get(Message.REQUEST_URL);
Object queryString = message.get(Message.QUERY_STRING);
log.error("Responding with HTTP status " +
response.getStatus() +" for "+ method + " " + url
+ "?" + queryString);
log.error("Responding with message body: " +
response.getEntity());
}
return response;
}
}
The response code and entity are populated but the method, url and
queryString always return null. I wondered if it was possible to get the
originating request info just to log some extra information.
The response handler is using an out message, and those properties are
available on the in message, which you can access like this:
message.getExchange().getInMessage()
Alternatively, you can inject JAX-RS UriInfo + Request (the latter will
give an HTTP verb) or MessageContext
Cheers, Sergey
Thanks
Jon
--
View this message in context:
http://cxf.547215.n5.nabble.com/Is-it-possible-to-get-the-originating-request-URL-in-a-Custom-Response-Handler-tp5712129.html
Sent from the cxf-user mailing list archive at Nabble.com.
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com