I have a SOAP webservice(spring ws)and need to save the response time of every request that I receive. I could create a servlet filter that measures time difference between HTTP Request and HTTP Response. But, I need to log the response time together with some values that I read from soap request envelope, and since at that time request is raw and needs to be unmarshalled, that's an expensive and redundant operation to unmarshall for every request.
So is there a way to calculate it using SpringWS? like in a payloadInterceptor?
I think you can use two tools.
AspectJ with its annotation @Before and @AfterReturning. The pointcut could be the method that receives the request (@WebMethod).
The JoinPoint object has the information of the method's parameters
I hope this can give you ideas to resolve your problem.
Yes, implementing an
EndpointInterceptor
is the best fit for this task, as it gives you access to the SOAP messages through theMessageContext
. See the Reference Documenation.