Showing posts from May, 2010

Intercepting method calls of @WebService annotated classes

I ran into this issue recently and I thought sharing this with everyone will help in saving some time.

I am making use of Metro + Spring for my web service implementation. I have a requirement that I should intercept all the calls in the web service implementation (the class that has is annotated with @WebService) and log the time taken to execute each call.

So I created the following AOP advice:

public class WebServiceMethodsAspect {
    @Around("execution(* com.mydomain.service.*Impl.*(..)) && args(request)")       
    public Object interceptWebServiceCall(ProceedingJoinPoint pjp,
            Object request) throws Throwable {
Once created the aspect I enabled the annotation based aspects using the following tag in my applicationContext.xml file:

< bean id="webServiceMethodsAspect" class="com.mydomain.aspects.WebServiceMethodsAspect"/>
I was expecting everything to be working fine…