WCF Data Services

Although we won't go into it deeply here, it's worth mentioning the availability of WCF Data Services as an alternative to RIA Services. WCF Data Services (Data Services, for short) is another data-centric communication technology built on the WCF stack that exposes data to clients as JSON- or ATOM-serialized RESTful resources using the OData protocol. The OData protocol specifies how a client can query, navigate, and update data exposed by a service. Using this protocol, the client can communicate with the service in a RESTful manner by retrieving data using a standard HTTP GET call, using specially constructed URIs, and sending updates to the server using a standard HTTP POST call.

Data Services shares a number of similarities with RIA Services and, in a way, you could consider the two to be sibling technologies, at times both jostling for attention and attempting to outdo each other. Both are built on top of WCF and conform to a pattern to expose data to clients, but each has a somewhat different focus. For now, RIA Services primarily targets Silverlight clients, whereas Data Services is client agnostic. While RIA Services generates code in the client project in order for the client to communicate with the services (an aspect that concerns some developers who are against “magic” code generation that they have no control over), Data Services does not need a link to the client project, and no code generation is required. Instead, Data Services provides a client library (System.Data.Services.Client.dll) to help the client interact with the service.

In a similar manner to RIA Services, Data Services exposes queryable endpoints by returning IQueryable expressions from operations. By using the client library, you can write LINQ queries on the client against these endpoints and have them executed on the server. This was one of the most powerful features provided by RIA Services, and it's also available, with a slightly different implementation, in Data Services.

It can be difficult to identify whether you should use RIA Services or Data Services in your project, and how the two differ. However, you can break it down to the following:

  • RIA Services has a rich model designed for the development of end-to-end Silverlight applications, with the server tightly linked with its client via the code generation process.
  • Data Services is designed simply to expose data as RESTful resources in a stand-alone manner that a range of clients can consume, such as reporting tools that can consume data exposed over HTTP and serialized as either ATOM or JSON.

Note that RIA Services can also expose data as RESTful resources that can be consumed by a range of clients, by enabling OData or exposing a JSON endpoint using the functionality provided in the WCF RIA Services Toolkit. Also, together with its ability to share code and validation logic with the client, among the numerous other features it provides, you will find that RIA Services is generally the best solution when writing an end-to-end Silverlight application. However, if you want your service to support a wide variety of clients without having a tight relationship to your Silverlight project, Data Services is a viable alternative.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.62.105