Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use WCF data services and when not?

For which applications or development scenarios the usage of WCF Data Services makes sense and when other technolgies are the better choice (for example WCF RIA Services, ADO Entity Framework, classical ADO.NET, simple services or whatever) ?

like image 258
Kottan Avatar asked Jun 23 '10 14:06

Kottan


1 Answers

WCF Data Services is a pretty easy and quick way to get your data model - collections and entities - out on the web. You can easily browse your collections, look at entities etc., all through standard HTTP / REST calls.

As long as you have mostly that - showing and displaying entities and collections of entities - it works really well. I don't really know the extra bonus that WCF RIA Services carry just yet - haven't investigated that too much.

WCF Data Services are based on a model representation of your data - that's where Linq-to-SQL or Entity Framework come into play and allow you to create that model, based on your physical database.

When you need to use something like method-oriented services, however - like "Insert customer", "Calculate total orders for customer" and so forth, then a SOAP-based WCF service will be more suited. A SOAP based WCF service defines a service contract (set of methods on your service) and allows you to call those methods on your service object.

SOAP is great when doing transaction-oriented business work - it's self-describing, e.g. your client can discover and interrogate the SOAP service (an area where REST sorely lacks - there's no "WSDL" or something comparable for REST services).

And if you're doing SOAP, I would also recommend using a model-based approach for your data - create a model of your database and expose methods on those entities to the outside world - again, using Linq-to-SQL, Entity Framework, NHibernate or some other modelling / ORM tool. I would not advise to use "classical" or "bare-bones" ADO.NET for most of your work - it's just too much grunt work and silly code - let a framework like Linq-to-SQL or EF handle that boring infrastructure stuff for you and concentrate on your actual business requirements and needs.

like image 58
marc_s Avatar answered Oct 23 '22 02:10

marc_s