Breaking up the annotations worked for me with a relatively simple web service. I imagine this would be unwieldy with a big project though.
Take the following interface:
Implement it using declarative transactions:Code:public interface ICalculator {
int add(int a, int b);
}
Create the web service implementation you want to expose and use Spring to inject CalculatorImpl:Code:public class CalculatorImpl implements ICalculator {
@Transactional
public int add(int a, int b) {
//do some database stuff requiring the transaction
return a + b;
}
}
Code:@WebService
public class CalculatorService implements ICalculator {
private ICalculator impl;
public void setICalculator(ICalculator impl) {
this.impl = impl;
}
@WebMethod
public int add(int a, int b) {
return impl.add(a, b);
}
}
