ADO.NET Data Services
Access data in the cloud with REST.
Data access protocols that use HTTP as the transport and adhere to the Representational State Transfer (REST) architectural style are challenging traditional binary and Extensible Markup Language (XML) formats for data-intensive Web applications. The primary characteristic of the REST model is the division of application state and functionality into resources, which are addressable by a Uniform Resource Identifier (URI). Web-based REST resources use HTTP on port 80 or secure HTTP (HTTPS or Secure Sockets Layer [SSL]) on port 443 to pass public or confidential data through corporate firewalls. Instead of describing the location (endpoint) of a SOAP service with a complex Web Service Definition Language (WSDL) file, RESTful services combine a URL with a query string to serve as the endpoint's URI and omit the SOAP envelope.
The Microsoft ADO.NET Data Services Framework, which almost everyone calls by its original "Astoria" code name, is a specialized Windows Communication Foundation (WCF) implementation that adds a RESTful front-end to the ADO.NET Entity Framework.
Astoria uses an HttpWebRequest with the GET method and query-string URIs to expose relational database schema metadata as XML files and data from relational databases as Atom <feed> elements with member entities as <entry> elements. WCF 3.5 adds support for Atom and JSON serialization to WCF 3.0. AtomPub is Astoria's protocol for implementing HttpWebRequest POST (create), PUT (update) and DELETE methods.
The use of XML syndication formats -- such as RSS or Atom -- as the wire format for data transfer is rapidly becoming universal for RESTful services. Although RSS engendered the Web's syndication phenomenon, Atom is ascendant because it and HTTP, URI and URL are Internet Engineering Task Force (IETF) standards. RSS, which is owned by the Harvard Law School, isn't extensible, and it's frozen at version 2.0.
Read-Only Atom Syndication Format (IETF RFC 4287) and the later Atom Publishing Protocol (AtomPub, RFC 5023) for creating and updating resources also benefit from widespread public contribution to the standards process. Google Inc. was one of the first to adopt Atom as the feed format for its free Blogger weblog service; Atom 1.0 and AtomPub underlie the widely used Google Data (GData) APIs for Google Services. (GData also supports RSS 2.0.)
The Visual Studio (VS) 2008 and .NET 3.5 Service Pack 1 (SP1) beta, released in May, integrate Astoria and the Entity Framework with VS 2008, including the Express editions. Clients for .NET 3.5 SP1 Windows or Web form projects can use the DataServiceQuery class from the .NET Client Library for ADO.NET Data Services Framework (System.Data.Services.Client) to translate LINQ to ADO.NET Data Services-better known as LINQ to REST-queries into GET URIs and query strings. For example, http://domain.com/ Northwind.svc/Customers('ALKFI') returns a single-entry feed with customer data for Alfreds Futterkiste and a reference link to a collection of associated Orders entities. The DataSvcUtil.exe tool autogenerates C# or Visual Basic classes that transform the returned Atom feeds into strongly typed entities defined by Common Language Runtime (CLR) classes. The DataServiceContext class enables maintaining state on the client for managing data changes.
Silverlight 2 beta 2 will include an Astoria Silverlight client that's compatible with VS 2008 SP1; installing the current VS 2008 SP1 beta requires removing the earlier Silverlight 2 beta 1 client beforehand.
Services Snap Together
Data in the Cloud
ADO.NET Data Services and ADO.NET Entity Data Model templates make creating simple services easy and quick. Start an ASP.NET Web Application or WebSite file system project, add a new ADO.NET Entity Data Model item, select a database connection from Server Explorer with the Entity Data Model Wizard, choose the tables, views or stored procedures to include and click Finish to create the complete model. Add a new ADO.NET Data Service item, name the service, import the Model Name Entities namespace, replace a couple of placeholders, and press F5 to display in the browser a default list of entities from the tables or views you selected. Astoria-enabling a Web form or Silverlight client takes a bit longer because DataSvcUtil.exe is a command-line code-generation tool.
ADO.NET Data Services has an expansive future; it's destined to become the on-premises counterpart of Microsoft's new Database as a Service initiative, SQL Server Data Services (SSDS). Francois Ajenstadt, director of project management for SQL Server, has said the ADO.NET Data Services and SSDS APIs will become more closely aligned as SSDS's release date nears. An "Astoria Offline" implementation with ADO.NET Synchronization services to SQL Server Compact 3.5 is in the works, but the team hasn't mentioned a release date. You also can expect Astoria -- and SSDS -- to play an important future role in Microsoft's fledgling Live Mesh project, which will support LINQ.