Uploaded image for project: 'Spring Web Services'
  1. Spring Web Services
  2. SWS-803

WebServiceTemple -> add logRequest method analogue to existing logResponse

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 2.1.1
    • Fix Version/s: 2.1.2
    • Component/s: Core
    • Labels:
      None

      Description

      Hi!

      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?

      THanks!

        Activity

        talang Tamás Láng created issue -
        arjen.poutsma Arjen Poutsma made changes -
        Field Original Value New Value
        Assignee Arjen Poutsma [ arjen.poutsma ]
        arjen.poutsma Arjen Poutsma made changes -
        Fix Version/s 2.1.2 [ 13606 ]
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        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;
            }
        }

        Show
        arjen.poutsma Arjen Poutsma added a comment - 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; } }
        arjen.poutsma Arjen Poutsma made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Won't Fix [ 2 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        52d 19h 3m 1 Arjen Poutsma 03/Dec/12 4:38 AM

          People

          • Assignee:
            arjen.poutsma Arjen Poutsma
            Reporter:
            talang Tamás Láng
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: