Hello group,
I very much want to diddle the response xml on it's way out to add
attributes and other bits. Unfortunately I seem to be at a loss of how
to accomplish this even though it seems like it should be very easy. I
am using CXF 2.1.1, JAXRS and JAXB if that is of interest.
I have written an Interceptor to test with modeled after what I think
is happening in the LoggingOutInterceptor, placed it in all different
locations on the interceptor chain to see what happens in the message
and I am not finding too much.
If I iterate through message.getInterceptorChain() I get:
org.apache.cxf.interceptor.MessageSenderInterceptor
org.apache.cxf.interceptor.LoggingOutInterceptor
org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor
com.mypackage.cxf.ContentsDumpInterceptor
org.apache.cxf.interceptor.MessageSenderInterceptor
$MessageSenderEndingInterceptor
If I iterate through message.getContentFormats() I get:
OutputStream
List
The list is filled with a ResponseImpl as that is what I am returning
from the method invocation.
If I try to print the OutputStream like the LoggingOutInterceptor does
nothing happens:
public void handleMessage(Message message) throws Fault {
StringBuilder s = new StringBuilder();
try {
CachedOutputStream cos = new
CacheAndWriteOutputStream(message.getContent(OutputStream.class));
cos.writeCacheTo(s);
LOG.info("~~~~~~~~My Message: " + s.toString() );
} catch (IOException e) {
e.printStackTrace();
}
}
Where does the XML live? How to I get at it? Please point me in the
right direction. This must be very simple.
-Anthony