An expanded Web Programming Model is now available in Windows Communication Foundation (WCF) 3.5. This Web Programming Model allows developers to build Services using a RESTful architecture. Services built using this new architecture approach is growing significantly. This Talking Point will cover the basics of REST versus SOAP/WS-*, and how to build Services using WCF 3.5 based on REST. We also cover Web feeds (RSS and/or ATOM) for Services to enable easy access to enterprise data (see ADO.NET Data Services to see this technology applied to Data Services).
REST is an architectural style that derives from the client-server architectural style. The basic premise of REST is to build client-server applications using the same principles that the World Wide Web is built on. The main concept behind REST as an architectural style is to follow the best practices of the web.
The constraints of REST are based on the idea that clients interact with resources (representations of data that we want to work with). Each resource is identified by a unique URI. We interact with resources by addressing the URI and using a uniform interface to tell the service what we want to do with a resources. Other constraints are that services should be stateless (to increase scalability), and that resources should have links to other resources and those links can drive the state of the application.
The basic premise of REST is to build client-server applications using the same principles that the World Wide Web is built on. (HTTP Methods):
Microsoft has adopted REST as a first class approach to Web Programming, examples of that are:
The reasons and benefits are many but mainly:
Building a RESTful Service involved 4 high-level steps:
WCF is a core building block within out platform for building systems that communicate over networks. It is built as an open framework that supports many styles of applications, like client-server, message oriented, or service oriented, etc. It abstracts away from the developer all the complexity of networked systems, so developers can focus on the business logic.
Although the underlying message model is based on the SOAP message format, with a Header and a Body, building RESTful services as possible with WCF even before .NET 3.5 (with considerably more plumbing code), but it is a testament of WCF’s truly open and extensible design.
With 3.5, WCF added both infrastructure support (bindings, etc.) as well as a programming model.
In ServicePack1 the team added:
This make building RESTful endpoints with WCF very straightforward, even if you don’t know a lot about REST.
WEB FEEDS and WCF
Feeds are a common way of exposing data on the web, particularly to automate posting machine-readable data for blogs and news. Organizations are finding feeds to be a very useful way to also expose various types of enterprise data. For instance, almost all of the data in a SharePoint portal can be exposed as a feed.
Syndication, the act of exposing data using web feeds relies in two typical formats: RSS and Atom. RSS is the older standard, and Atom is quickly become the more dominant (although many sites/endpoints expose both formats) because Atom has a richer model for non-HTML data as well as linking.
The support built into WCF for feeds is built on top of the base functionality we mentioned above.
The basic idea behind the WCF support for feeds it to abstract away from the developer the need to know the various feed formats (in this version of WCF that’s RSS 2.0 and Atom 1.0). This is done by separating the data from the serialization model.
Developers can simply take data and push it into the WCF OM (Object Model). Then take the WCF OM and pass it to the formatter. The formatter takes care of turning the WCF OM (which is layered on top of the data) into the correct feed format.
The WCF OM is closer to the Atom model, since the Atom model is as we said before, a little richer in terms of its data.
Finally, the WCF object model from WCF relies in two core objects: SyndicationFeed and SyndicationItem. The SyndicationFeed represents the whole feed, and each SyndicationItem represents an entry. SyndicationFeed has an Items property which holds onto the individual items.
In Part II we will explore:
REST as an architectural style encourages interoperable, scalable web services, while WCF 3.5 provides the support for building services using this architectural style. Building RESTful services in .NET is an elegant integration of simplicity and power. We leverage the simplicity of the fundamental web protocols with the power of our framework and development tools.