I am using Apache CXF for my webservices. I've created an instance of AbstractSoapInterceptor
. In its public void handleMessage(SoapMessage message) throws Fault
method I would like to print the XML content of the intercepted message to the console. How can I achieve that?
views:
28answers:
2
A:
Check this out and search for INBOUND INTERCEPTOR. Will place it here for reference...
public class InterceptorMensajeSOAPIn extends AbstractSoapInterceptor {
private static Logger log =
Logger.getLogger(InterceptorMensajeSOAPIn.class);
private SAAJInInterceptor saajIn = new SAAJInInterceptor();
public InterceptorMensajeSOAPIn(){
super(Phase.PRE_PROTOCOL);
getAfter().add(SAAJInInterceptor.class.getName());
}
public void handleMessage(SoapMessage message) throws Fault {
SOAPMessage soapMessage = getSOAPMessage(message);
try {
soapMessage.writeTo(System.out);
} catch (Exception e) {
e.printStackTrace();
}
}
private SOAPMessage getSOAPMessage(SoapMessage smsg){
SOAPMessage soapMessage = smsg.getContent(SOAPMessage.class);
if (soapMessage == null) {
saajIn.handleMessage(smsg);
soapMessage = smsg.getContent(SOAPMessage.class);
}
return soapMessage;
}
}
Aaron
2010-10-19 14:36:51
+1
A:
Any reason you cannot just use the LogggingInInterceptor that is shipped with CXF? You could just grab the code for that and use that as a basis, but in 2.3, the LoggingInInterceptor was enhanced to allow specifying a printstream and such to use, so it might "just work".
Daniel Kulp
2010-10-19 15:00:24