It is advised that 'exclude=true' on @Webmethod not to be used if there is an SE Interface Declared. It can be done though and if done, the method is excluded. So, why is it advised so?
posted 3 years ago
First of all, where have you read such an advice?
If it is in the Java SE API documentation of the annotation, then it only says:
This member-value is not allowed on endpoint interfaces.
Thus, it does not advice against using the @WebMethod annotation, just saying that it is not allowed on interfaces that endpoint implementation classes implement.
A possible reason for recommending not to use the @WebMethod annotation is that there is little reason in declaring a method in an endpoint implementation class public and then annotate it with @WebMethod(exclude="true").
If you have a method that is public in an endpoint implementation class and it is not used in the web service but it is called from another part of the system, then there may be reasons to consider separation of concerns and have two different service implementation classes.