cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpcook01 <jonathan.c...@erars.plus.com>
Subject Is it possible to get the originating request URL in a Custom Response Handler?
Date Tue, 07 Aug 2012 11:02:56 GMT
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.

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.

Mime
View raw message