cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From santhosh <>
Subject How to get the message content as a string from RequestHandler?
Date Wed, 14 Dec 2011 14:00:07 GMT

I am new to Apache CXF and RESTFul web services,
I have written an Interceptor for transaction logging by implementing the
below interface and it works fine,

org.apache.cxf.jaxrs.ext.RequestHandler .

Issue is,
The request contains xml data and  I have to get that xml data as a string.

I have implemented the org.apache.cxf.jaxrs.ext.RequestHandler interface
like below, but I am not able get the content. Please help me if there is
any way to get the xml as string from message object. 

public Response handleRequest( Message message, ClassResourceInfo
classResouceInfo )

    Set<Class&lt;?>> contentFormats = message.getContentFormats();

    if( contentFormats != null )
	    for( Class<?> contentFormat : contentFormats )
	       Object contentMessage = message.getContent(contentFormat);

               if( contentMessage.toString().startsWith("<?xml") )
		 String content = contentMessage.toString();


View this message in context:
Sent from the cxf-user mailing list archive at

View raw message