views:

4739

answers:

3

Ok, all these methods of getting data in a Silverlight control are confusing me.

I've looked at ADO.Net Data Services, Web Service and Ailverlight-enabled WCF services. I'm just not sure when one is appropriate to use over another. What pros/cons do each offer?

I've built a web app, and a silverlight control. I will be adding one of those 3 options to my web application and consuming it from my silverlight component.

+2  A: 

If you have to choose between a web service and a WCF service, my advice is to go with WCF. It's more modern and more powerful technology. As for ADO.Net Data Services - you can use that if all you need is to retrieve/commit some data from/to a database back on the server.

Boyan
ADO.NET Data Services also allows you to commit changes - it isn't just for query.
Marc Gravell
@Marc: You're right, of course. I've edited my answer.
Boyan
+6  A: 

From the silverlight perspective, WCF is heavily constrained anyway, so most of the usual benefits of WCF don't apply. However, it is still a fairly nice, consistent programming model.

WCF is primarily a SOAP stack, so it is very good at presenting data as rigid operations. ADO.NET Data Services is a REST stack, and allows very expressive queries to be performed dynamically over the wire.

I don't know how it is in Silverlight, but a regular ADO.NET Data Services proxy (the bit on your client app) has very rich support for both query and data changes back to the server. Note that applying changes requires either a: Entity Framework, or b: lots of work. But you should get query and update very cheaply with this approach.

With WCF, you get a much more controlled stack, so you will need to code all the distinct operations you want to be able to do. But this also means you have a known attack surface etc; it is much harder to exploit a locked down API like a fixed SOAP endpoint.

Re regular web-services (pre-WCF): only go down that route if you want to support very specific legacy callers.

Marc Gravell
So as far as payload goes, is one more heavy (in terms of bandwidth or processing)?
Jeremy
REST (i.e. ADO.NET Data Services) is simpler and *generally* more light weight. But it depends on the specific scenario.
Marc Gravell
For info, I'm currently blogging on implementing a custom (non-Entity-Framework) ADO.NET Data Services service; just in case it is helpful: http://marcgravell.blogspot.com/
Marc Gravell
+4  A: 

I know this is old, but I just wanted to add my 2 cents.

I would highly recommend using WCF; and use the WCF Service Library project over the Silverlight-enabled web service. They are both essentially the same, but the Silverlight-enabled web service changes the binding to basic instead of ws*. It also adds an asp.net compatibility mode attribute.


  • WCF is usually faster: See "A Performance Comparison of Windows Communication Foundation (WCF) with Existing Distributed Communication Technologies" @ http://msdn.microsoft.com/en-us/library/bb310550.aspx

  • WCF encapsulates asmx, wse, msmq, enterprise services, and remoting.

  • WCF services can be included and run within iis, windows forms, etc.

  • WCF isn't restricted to using HTTP, but with minimal configuration can also use tcp, named pipes etc.

  • complex data types are easier to expose and serialize.

  • WCF just scales really well. Plus, they can be used to incorporate workflows from WF.


There's probably not a wrong technology to use, but it seems as if Microsoft is going to be moving forward with WCF. Plus, it's just so much easier to write one code base that can be exposed so many different ways with just a few configuration changes to the WCF service.

I recommend not using the Silverlight-enabled web service, just because the programming structure is set up a little better with the WCF model, but this is probably a matter of opinion.

codefoo
-1: Scott, I'm downvoting because: 1) I don't see that this answer adds much to what was already there, and 2) You've got it backwards as far as using the Silverlight-enabled WCF service. Since he's using Silverlight, he needs to not use wsHttpBinding!
John Saunders
No problem. I thought my answer added authority on where one might find actual statistics on the performance of WCF since none of the other comments did.The SL-enabled wcf service and the wcf service are the same thing. The only difference is that when creating a SL-enabled service it automatically changes the binding to basichttpbinding and adds the ASP compatibility mode line. Both of which can be done in the wcf service. Unfortunatlely, the silverlight-enabled wcf service does not set itself up to use a interface as the contract which I refer to as the better programming structure.
codefoo