Exam 70-487: Accessing Data - How to choose the Appropriate Data Access Technology - WCF Data Services?
Since different applications are written in different programming languages, they often cannot communicate with each other out of the box. So,
if you want to make the application available to outsiders, the only option we used to have was to build a web service.
A Web service enables this communication by using a combination of open protocols and standards. Once upon a time, this was mostly done with XML, SOAP and WSDL. A Web service uses XML to tag data, SOAP to transfer a message and finally WSDL to describe the availability of services.
But, during the 2000-2010 decade, the development landscape underwent significant changes with the formulation of the following protocols and architectural styles:
Representational State Transfer (REST): First defined by Roy Fielding in 2000,is a software architectural style that defines a set of constraints to be used for creating web services.
Open Data protocol (OData): Initiated by Microsoft in 2007, is a standard that defines a set of best practices for building and consuming REST-ful APIs.OData uses the entity-relationship conventions of the Entity Data Model (Read more about it here)to expose resources as sets of entities that are related by associations.
WCF Data Services, a successor to or formerly known as the ADO.NET Data Services, is the main mechanism from Microsoft to expose the above technologies (REST, JSON, oData). Quite frankly, as an Architect, Developer or Engineer, you must master OData, REST, JSON in today's service oriented environment. WCF Data Services can expose data that originates from various sources as OData feeds.
But for now, we focus on WCF Data Services concept itself: In a typical scenario, you build a WCF Data Service by performing the following steps:
- Create an ASP.NET Web Application
- Use the Entity framework to define an EDM
- Add a Data Service to the Web Application (which is there just to host the application and expose it over the web)
- Enable access to the service
- Data is exposed using OData, resources are addressable via URIs, meaning that anyone can consume them from any plateform and device.
- WCF data services are accessed over HTTP, so someone can literally query your application without writing a single line of code.
- Very powerful queries can be constructed with very simple semantics unlike the need to know T-SQL in the case of other Data Access technologies.
- WCF Data Services provides a feature known as Interceptors, enabling to build a pretty sophisticated business logic.
If you want to create a WCF Data Services feed for practice:
Download the NorthWind sample database (sql script) from nugget and run the scripts in SSMS
- Open SSMS.
- Connect to the target SQL Server.
- Open the script in a new query window.
- Run the script.
Accessing resources with WCF data Service