I have a problem but first i want to know if im working on the best solution.
I am making an application that will sit on hundreds of client machines and send data to/retreive data from a server. The server will get that data and store/process it.
I want the client apps to be as lightweight as possible so i want the server to pass/receive the data in the form of classes. For example
Client requests User by userID
Server responds with class UserDetails which has user name, id, and personal info.
Another example would be
client requests a project
server responds with ProjectDetails class which has project id, name, description, details AND a list of Activities (this is another class, so should be implemented as an ActivitiesCollection)
I am just starting out on this and found a lot of people saying WCF services are the way to go but i have never written one before. Is this true? and if so, how do i pass complex classes to/from the WCF service?
Thanks all 🙂
~Dave
A WCF service consists of contracts – the service contract defines the behavior of the service (e.g. your service methods that can be called), and then there’s the data contract which defines what data gets passed around.
Those are simply attributes on .NET classes, that expose them to the WCF runtime.
In your case, you’d probably have something like:
and then for the data:
WCF is very flexible and gives you a lot of control over how and what to send around, and it handles all the serialization and other issues for you – automagically. No need to mess around with angle bracket soup yourself!
Check out the WCF Developer Center for lots of good content, how-to videos, articles and more – should help you get started quickly!
Marc