I am trying to perform formal auditing of my Spring web services requests/responses.
I have this in place in my Spring configuration:
<ws:interceptors>
<bean class="org.springframework.ws.soap.server.endpoint.interceptor.SoapEnvelopeLoggingInterceptor"/>
</ws:interceptors>
This is fine, and logs the requests and responses to my JBoss log file. What I want though, is to be able to adapt this and log these requests/responses a little cleaner and how can I get hold of of the data, so I can write to an audit record in the DB.
How can I adapt this above so I can map to one of my beans or similar and get hold of of the data in the requests and responses?
You should just be able to create a subclass of SoapEnvelopeLoggingInterceptor and override
logMessage(String) to do what you want. Example:
<ws:interceptors>
<bean class="org.mypackage.SysErrLoggingInterceptor"/>
</ws:interceptors>
package org.mypackage;
public class SysErrLoggingInterceptor extends SoapEnvelopeLoggingInterceptor {
@Override
protected void logMessage(String message) {
System.err.println(message);
/* Example, here you could be logging to DB or whatever you want */
}
}
来源:https://stackoverflow.com/questions/14197918/spring-how-can-i-adapt-soapenvelopelogginginterceptor-to-log-the-data-more-for