I am using WSDL-first. I have WSDL and generate Java code using Maven plugin 'cxf-codegen-plugin'. Using Code-first one can write DTO for example:
public class ServiceSearchCriteria {
private String phoneNumber;
private String businessId;
public boolean validateSearchCriteria() {
if ((phoneNumber != null) || (businessId != null)) {
return true;
}
return false;
}
//... setters/getters etc.
}
So using Code-First (Java-First) it is easy to write DTO with validation method. Client can check if search criteria are good fulfilled. This class would be returned by WebService class annotiated with @WebService. And this will work.
But how to write such DTO (with some method) using WSDL-First approach?
I very like WSDL-First approach (it has many advantages but this is not place to write about them) but I would like to add method... just not to write "anemic domain model" and allowing client to check search criteria fulfilled before sending to server.