I have a webservice which expects a certain request format. When I send a non valid request format, I have the following error :
<faultcode>soap:Client</faultcode>
<faultstring>Unmarshalling Error: unexpected element (uri:"", local:"aaaa"). Expected elements are <{}xxx>,<{}yyy></faultstring>
When this occurs I need to send an e-mail. In this e-mail I need the incoming request (the XML I sent to the webservice).
I tried by implementing a CXF interceptor:
public class ExceptionInterceptor extends AbstractSoapInterceptor {
/**
* Logger
*/
private final static Logger LOGGER = LoggerFactory.getLogger(ExceptionInterceptor.class);
/**
* Constructeur
*/
public ExceptionInterceptor() {
super(Phase.PRE_LOGICAL);
}
public void handleMessage(SoapMessage message) throws Fault {
Fault fault = (Fault) message.getContent(Exception.class);
Throwable ex = fault.getCause();
if (ex instanceof UnmarshalException) {
LOGGER.error("Error in incoming message", ex);
// TODO : send email
}
}
}
but... how can I get the original message I sent to the webservice here? Apache CXF interceptors are not much documented. :(
Thanks in advance !
Hejk