[SWS-803] WebServiceTemple -> add logRequest method analogue to existing logResponse Created: 11/Oct/12  Updated: 03/Dec/12  Resolved: 03/Dec/12

Status: Resolved
Project: Spring Web Services
Component/s: Core
Affects Version/s: 2.1.1
Fix Version/s: 2.1.2

Type: Improvement Priority: Minor
Reporter: Tamás Láng Assignee: Arjen Poutsma
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified



I want to log the webservice requests and responses in the application I'm currently working on.
My approach would be to use AOP and watch the methods you use in your code for logging.
I found "logResponse(MessageContext messageContext)throws IOException" method in the WebServiceTemplate, for that I could create a pointcut.

But I would need something for the request logging as well and now the request logging currently located in the method:
sendRequest(WebServiceConnection connection, WebServiceMessage request) throws IOException
which is also good, just It would be good to separate the logging part imho.
So you could add a similar method to logResponse.

Additional question is that I found that there are so called TracingLogger's creatd with logFactory. Maybe instead of thinking in AOP I could use them with defining my own somehow?

What do you think?


Comment by Arjen Poutsma [ 03/Dec/12 ]

Instead of using AOP, I think it's a lot easier to just use a org.springframework.ws.client.support.interceptor.ClientInterceptor for logging request and response, and register that with the template. Something like:

public class LoggingClientInterceptor implements ClientInterceptor {

    private static final Log logger = LogFactory.getLog(LoggingClientInterceptor.class);

    public boolean handleRequest(MessageContext messageContext) throws WebServiceClientException {
        logger.debug("Request: " + messageContext.getRequest());
        return true;

    public boolean handleResponse(MessageContext messageContext) throws WebServiceClientException {
        logger.debug("Response :" + messageContext.getResponse());
        return true;

    public boolean handleFault(MessageContext messageContext) throws WebServiceClientException {
        logger.debug("Fault:" + messageContext.getResponse());
        return true;
Generated at Wed Dec 12 11:46:08 UTC 2018 using JIRA 7.9.2#79002-sha1:3bb15b68ecd99a30eb364c4c1a393359bcad6278.