I'am little confused about how business logic should be implemented using web services. For example, think about an education management application. There are simply students, teachers and courses. Now, the server side of the application may provide getStudents
operation via a WSDL interface. This operation returns list of Student
elements.
According to object oriented paradigm a class should have a certain responsibility. It should hide its internal state and one can reach its data only using its operations. But at the client side a Student
class is only a data bag. There is no logic so no responsibility here.
Another problem is that there is no reference semantics at the client side. Normally, a student is associated with
some courses. But in the implementation a Student
object has
list of Course
objects or it may hold some identifier for courses.
Finally, using web services (by WSDLs) seem to convenient for access remote data but not for execute business logic remotely. Am I right, or do I miss something important about web services?
Edit:
My intent is implement business logic at server side. For example suppose that a have classes in server side like that:
class Student
{
//some properties like name, courses, etc.
double calculateGPA(); //calculates average grade using course credits.
//other operations like getName()
}
class SchoolRepository
{
List<Student> getStudents();
List<Course> getCourses();
//other operations
}
Now, I can create WSDL which provide SchoolRepository
interface. So, client get list of students. But they cannot reach business logic implemented in calculateGPA()
directly. I may provide another WSDL interface for that. But it breaks data and behavior encapsulation.