Contract Projections in WCF declarative services

As my friend Jesus mentioned in the post "Using XAML serialization in WCF 4.0", WCF 4.0 introduces a new way to implement services that are totally defined in XAML, which receive the name of "declarative services". In the past, creating a simple service involved three basic steps,

Define the service contract

Implement the service contract

Host the service implementation

#1 and #2 were all done in an imperative .NET programming language such as C# or VB.NET. Today, thanks to this new feature, we will able to define the service interface (#1) using XAML and implement the service (#2) using a declarative workflow (XAML too).

This was announced as part of the Microsoft's Oslo modeling vision in the last PDC.

Aaron Skonnard has recently written an excellent article for the MSDN, "WCF and WF Services in the .NET framework 4.0, and Dublin", where he discusses all these new features more in detail, and the role of dublin in that vision. Something I found interesting in that article was the fact that he mentioned "Contract Projections" as part of "declarative services".

A contract projection allows separating the logical contract definition from the representation of the messages that are sent or received. We will able to have a single contract definition and specify different messaging styles like "SOAP" or "REST/POX" using a contract projection.

As in the example shown in the article, a regular WCF service definition for a calculator service made in C# would look like this,

As you can see, we will able to have a single service implementation (or XAML workflow), and multiple contract projections or "KnownProjections" (for the different messaging styles) to get access to that service.

With this new feature, it looks like REST/POX will be officially supported for consuming declarative services. (I talked in the past about exposing workflow services with REST).

As part of the PDC bits (The code that was distributed in a VPC), there is a interface "IContractProjection" for defining new kind of projections,