locked
ado.net data service Vs wcf/asp.net web service for binding to sql db RRS feed

  • Question

  • For silverlight 2 beta2 controls like datagrid, which is the best approach for binding to sql server database? ado.net data service or wcf/ asp.net web service. The tutorials here show about wcf web service. but there are many blogs now which are using ado.net data service. Which is a better option?

    Wednesday, July 30, 2008 2:07 AM

Answers

  • Hello, they all have their own advantages and disadvantages.

    ASMX advantage: It's the only option available if your server doesn't support .NET 3.0 or higher.

    ASMX disadvantage: Not based on standard. If you don't use it carefully, your service will not be interoperable. This means it can't be used by Silverlight, Java, Flex, or any non-full-.NET platforms. For example, a common mistake in ASP.NET development is to make a ASMX service to return a DataSet, which is only supported in full .NET. For ASP.NET it's OK because ASP.NET runs on full CLR. But Silverlight is not. Supports SOAP only, no REST.

    WCF advantage: Based on standard. With a few configurations (basicHttpBinding, Service/Operation/DataContract, DataMember), you'll be able to call the service from any clients: WPF, Silverlight, Java, Flex, PHP, etc... Supports both SOAP and REST.

    WCF disadvantage: Requires at least .NET 3.0 on the server. Not so easy to consume a WCF REST service (require manually parse the returned data).

    Data Service advantage: Very easy to create. You do not need to create any quires on the server side. You can directly create LINQ queries on the client. It has a kind of built-in REST SDK for Silverlight.

    Data Service disadvantage: Requires .NET 3.5 SP1 on the server. Supports REST only, no SOAP.

     

    Then it comes the difference between SOAP and REST:

    SOAP advantage: A lot of tools, such as Visual Studio, can generate a proxy class from a WSDL file. Thus it's very easy to invoke the service from the client. It's also very mature. It's a w3 standard. A lot of enterprise frameworks are built upon SOAP/WSDL/UDDI.

    SOAP disadvantage: Overread. Compared with a REST service, the data being exchanged on the network is often larger. If you want to send binary format, you need to use MTOM, which is not supported by Silverlight. It's also not so easy to be extended.

    REST advantage: Very agile. You can use any format: XML, JSON, plain text, binary, etc. Can be directly requested with a web address, similar to request a web page. You can try your best to reduce network traffic.

    REST disadvantage: No standard yet (other than a few commonly used standard such as RSS). Every vendor can decide what format they want to use. Not so easy to access the service from a client application without SDKs. You need to manually parse the result returned by the service and convert them to your own objects. That's where Data Service comes to help. Most REST service providers, such as Windows Live and Google, provide SDKs for all major platforms.

     

    That being said, if your scenario is very simple, in which you only need to return some data from a database and display them in a DataGrid, and you don't care too much about network traffic, I think WCF with SOAP service is your best choice.

    Tuesday, August 5, 2008 4:23 AM

All replies

  • Hello, they all have their own advantages and disadvantages.

    ASMX advantage: It's the only option available if your server doesn't support .NET 3.0 or higher.

    ASMX disadvantage: Not based on standard. If you don't use it carefully, your service will not be interoperable. This means it can't be used by Silverlight, Java, Flex, or any non-full-.NET platforms. For example, a common mistake in ASP.NET development is to make a ASMX service to return a DataSet, which is only supported in full .NET. For ASP.NET it's OK because ASP.NET runs on full CLR. But Silverlight is not. Supports SOAP only, no REST.

    WCF advantage: Based on standard. With a few configurations (basicHttpBinding, Service/Operation/DataContract, DataMember), you'll be able to call the service from any clients: WPF, Silverlight, Java, Flex, PHP, etc... Supports both SOAP and REST.

    WCF disadvantage: Requires at least .NET 3.0 on the server. Not so easy to consume a WCF REST service (require manually parse the returned data).

    Data Service advantage: Very easy to create. You do not need to create any quires on the server side. You can directly create LINQ queries on the client. It has a kind of built-in REST SDK for Silverlight.

    Data Service disadvantage: Requires .NET 3.5 SP1 on the server. Supports REST only, no SOAP.

     

    Then it comes the difference between SOAP and REST:

    SOAP advantage: A lot of tools, such as Visual Studio, can generate a proxy class from a WSDL file. Thus it's very easy to invoke the service from the client. It's also very mature. It's a w3 standard. A lot of enterprise frameworks are built upon SOAP/WSDL/UDDI.

    SOAP disadvantage: Overread. Compared with a REST service, the data being exchanged on the network is often larger. If you want to send binary format, you need to use MTOM, which is not supported by Silverlight. It's also not so easy to be extended.

    REST advantage: Very agile. You can use any format: XML, JSON, plain text, binary, etc. Can be directly requested with a web address, similar to request a web page. You can try your best to reduce network traffic.

    REST disadvantage: No standard yet (other than a few commonly used standard such as RSS). Every vendor can decide what format they want to use. Not so easy to access the service from a client application without SDKs. You need to manually parse the result returned by the service and convert them to your own objects. That's where Data Service comes to help. Most REST service providers, such as Windows Live and Google, provide SDKs for all major platforms.

     

    That being said, if your scenario is very simple, in which you only need to return some data from a database and display them in a DataGrid, and you don't care too much about network traffic, I think WCF with SOAP service is your best choice.

    Tuesday, August 5, 2008 4:23 AM
  • Thanks.. nicely detailed.. that was helpful... i think i will go with wcf

    Tuesday, August 5, 2008 10:46 AM