I am developing a webservice using spring soap implementation and hence my service class is annotated with @Endpoint annotation. Now, I want to use SPRING AOP for application logging which I have already implemented. However, as I have noticed, until I execlude my service class from the pointcut expression, I get no endpoint mapping found exception when my webservice is invoked. When I exclude the service classes from AOP's scope, things work fine again. Any idea on this?
UPDATE:
My logger class
package com.cps.arch.logging;
@Component
@Aspect
public class LoggerAspect {
private static final Logger logger = LoggerFactory.getLogger("Centralized Payment System");
@Before("(execution(* com.cps..*.*(..)) and not execution(* com.cps.service..*.*(..)))")
public void logBefore(JoinPoint joinPoint) {
logger.info("Execution Start : "+"Class: "+joinPoint.getTarget().getClass().getName()+
"Method: "+joinPoint.getSignature().getName());
}
}
My Service Endpoint:
package com.cps.service.impl;
@Endpoint
public class EndpointIntegrationServiceImpl implements EndpointIntegrationService
{
private static final String NAMESPACE_URI = "http://www.example.com/cps/model";
@Autowired
public MYBO myBO ;
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "SaveDataRequest")
public void saveData(@RequestPayload
SaveDataRequest data) {
//business layer invocation
}
}
My WS Configuration
@EnableWs
@Configuration
@ComponentScan(basePackages={"com.cps"})
public class WebServiceConfig extends WsConfigurerAdapter
{
@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
servlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean(servlet, "/ws/*");
}
@Bean(name = "MyWsdl")
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema schema) {
DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
wsdl11Definition.setPortTypeName("MyPort");
wsdl11Definition.setLocationUri("/ws");
wsdl11Definition.setTargetNamespace("http://www.example.com/micro/payment/PaymentManagement");
wsdl11Definition.setSchema(reconciliationSchema);
return wsdl11Definition;
}
@Bean
public XsdSchema schema() {
return new SimpleXsdSchema(new ClassPathResource("XSD/MySchema.xsd"));
}
@Override
public void addInterceptors(List<EndpointInterceptor> interceptors) {
interceptors.add(validationInterceptor());
}
@Bean
ValidationInterceptor validationInterceptor() {
final ValidationInterceptor payloadValidatingInterceptor = new ValidationInterceptor();
payloadValidatingInterceptor.setSchema(new ClassPathResource(
"XSD/MySchema.xsd"));
return payloadValidatingInterceptor;
}
}
Sorry but I had to change few of the variable/class names to adhere to company policy. So as you can see I had to put the "not execution" part in the AOP to make my webservice work. If I remove that part, I get 404 error.