WCF Tutorial
www.Learn2Expert.net A new ASP.Net MVC 4, SSIS, Interview Q/A tutorial - Visit - www.Learn2Expert.net
Skip Navigation LinksHomeParts of ODataOData Protocol No of Views: 21924

OData Protocol

OData protocol is REST based protocol, which internally uses the HTTP for communication. It also defines how the OData model (Entity Data Model) will be available in wire.

Similar to REST, all the resource from service are queried using URL and it uses standard REST based verbs for communication like

  • GET: Reads data from entities
  • PUT: Updates an existing entity
  • POST: Creates a new entity
  • DELETE: Removes an entity
  • MERGE: Updates an existing entity, but replaces only specified properties

Data model exposed from OData service can be views by appending "$metadata" in query url, which returns the EDM schema in xml format and it is called as "conceptual schema definition language (CSDL),"

Example: http://localhost/ODataSample_01/MyODataService.svc/$metadata

OData uses the same type of authentication mechanism like REST to secure the data. It uses HTTP Basic Authentication over SSN. It can also use OAuth to authenticate based on the scenario.

OData provides two set of option to serialize and transfer data through network using OData protocol. Most commonly Atom type is used for communication.

  1. Atom/AtomPub (feeds)
  2. JSON

Below diagram explains about how the data from relation data source is mapped to oData data model and then to Atom data model

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.