WCF Tutorial
www.Learn2Expert.net A new ASP.Net MVC 4, SSIS, Interview Q/A tutorial - Visit - www.Learn2Expert.net
Skip Navigation LinksHomeWCF Data Service 4.5 No of Views: 28879
WCF tutorial | WCF Data Service 4.5

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

  1. Any client who supports the OData can consume the Data service and use the exposed resources
  2. Microsoft has provided predefined client libraries for different platform like iPhone, Android, Silverlight etc to consume the Data service.
  3. It allows the resources to be read or updated using Atom pub feeds or JSON (JavaScript Object Notation)
  4. Data service used the Entity Data Model framework to expose the data from different source like Relational database, Cloud, etc
  5. 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

  6. 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
  7. OData feed can represent data in Atom, JavaScript Object Notation (JSON), and as plain XML
  8. Data Service uses the existing hosting application like ASP.Net, WCF, IIS for its operations like caching, authenticating etc
  9. 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.