WCF Data Service 4.5
WCF Data Service is a .net component used to expose or consume data using OData protocol in form of REST (Representational State Transfer). Before .net framework 4.5 it was called "ADO.Net Data Service". It is also a WCF service but it is intended to communicate data using OData (atom feeds or JSON) using HTTP verbs like GET, PUT, POST, DELETE etc.
Below are the set of information about the WCF Data service
- Any client who supports the OData can consume the Data service and use the exposed resources
- Microsoft has provided predefined client libraries for different platform like iPhone, Android, Silverlight etc to consume the Data service.
- It allows the resources to be read or updated using Atom pub feeds or JSON (JavaScript Object Notation)
- Data service used the Entity Data Model framework to expose the data from different source like Relational database, Cloud, etc
-
Resource exposed from WCF Data Service can be reading using URL
http://localhost:24641/MyDataService.svc/People(55)?$select=FirstName,LastName :: This return the People information whose having ID= 55 and it return only First and Last name information
http://localhost:24641/MyDataService.svc/People()?$format=json :: This return all People information in JSON format
- This is mainly intended for client application which does not use .Net framework. So this service make sure that client can parse and access the data which is transmitted using standard HTTP protocol
- OData feed can represent data in Atom, JavaScript Object Notation (JSON), and as plain XML
- Data Service uses the existing hosting application like ASP.Net, WCF, IIS for its operations like caching, authenticating etc
- Data service exposes any data structure that implements the IQueryable interface. If data structure implements the IUpdatable interface - create, update, delete operations on data are supported.
Tips!
- Always create the service with Interface->Implementation format, mention the contract in Interface.
- Define the service in Class library and refer the class library in Host project. Don’t use service class in host project.
- Change the instance mode to per call as default.
- Always catch exception using try/catch block and throw exception using FaultException < T >.
- Logging and Include exception should be enable while compiling the project in debug mode. While in production deployment disable the logging and Include exception details.
|