comment inline
doshi_milan wrote:
Thanks for the reply.Actually I was able to retreieve atleast the Request
XML.
I, now, have a class DHCLOutInterceptor extends
org.apache.cxf.interceptor.LoggingOutInterceptor .I override the
handleMessage(org.apache.cxf.message.Message message) method as follows :
public void handleMessage(org.apache.cxf.message.Message message) {
MessageExchange exchange =
message.get(javax.jbi.messaging.MessageExchange.class);
NormalizedMessage nm = exchange.getMessage("out");
Source content = nm.getContent();
try {
String body = (new
SourceTransformer()).toString(content);
System.out.println("ODSLogOutInterceptor:handleMessage:
body:\n"+body);
} catch (TransformerException e) {
::
}
Strangely, although I have configured it as an OUTBOUND intrerafce I AM
NOT ABLE TO access the response XML. The NormalizedMessage object continues
to be null. <br/> If I make it 'in' instead of 'out' I am able to get the
entire request XML (which is very good).However what do I do to get the
outbound response XML? Can someone please explain me what am I missing ?
If you want to see the outbound message of cxf se endpoint, you should
write an interceptor with phase like PRE_STREAM, the
LoggingOutInterceptor should be exactly same as your scenario, take a
look at class.
The bean.xml looks like this :
<cxfse:endpoint >
<cxfse:pojo>
<bean class="com.company.ods.osl.mydata.OdsPriceDataImpl" />
</cxfse:pojo>
<cxfse:inFaultInterceptors>
<bean class="com.company.ods.osl.mydata.ODSFaultInterceptor"/>
</cxfse:inFaultInterceptors>
<cxfse:outFaultInterceptors>
<bean class="com.company.ods.osl.mydata.ODSFaultInterceptor"/>
</cxfse:outFaultInterceptors>
You need configure outInterceptors here, not outFaultInterceptors
Thanks for any feedback!
Milan
Freeman Fang wrote:
doshi_milan wrote:
I am using CXF within Servicemix.
I want to know how would I be able to intercept XML request / response
within my code ? I have created a user defined interceptor which extends
from org.apache.cxf.interceptor.LoggingInInterceptor and similarly
another
use defined Intercepor which extends from
org.apache.cxf.interceptor.LoggingOutInterceptor. I have this in the
xbean.xml file as follows :
I can't see your xbean.xml content here, :-)
I am able to override the handleMessage method. I know that
LoggingInInterceptor can directly log the XML but what I want is to
retrieve
certain values etc within the interceptor. Thus for now, I want to see
how
can I retrieve the ENTIRE message within the interceptor. This should be
very easy as the logging method probably does it but it is not available
to
us. I failed to get any sample or documentation. I do not even know if
LoggingInInterceptor /LoggingOutInterceptor are thr right interceptors to
be
used.
The LoggingInInterceptor should be what you want, you mean you can't
find the source code of LoggingIn/OutInterceptor? They are in cxf code
base, and you can find those from
http://svn.apache.org/repos/asf/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/
Any help will be much appreciated.
Thanks!
Milan Doshi