You are on page 1of 22

INTRODUCTION TO ODATA

WHAT IS ODATA
A web protocol for querying and updating data.  Built on top of technologies like http, AtomPub and JSON.  Enables a standardized way for data to be available over the web.  OData is RESTful service style as SOAP is to RPC.

ODATA : UNIFORMITY
Uniform way of representing structured data – JSON & XML  Uniform URL Conventions – Navigation, Filtering, Sorting, Paging  Uniform Operations

– GET, POST, PUT DELETE always mean the same

ODATA ORG

ATOM PROTOCOL
OData is layer on top of Atom Publishing Protocol.  Atom is simple way of exposing ‘feed’ of data.

ODATA COMPONENTS
A Service definition language  Error handling  Dataset paging  Advanced Queries  Batch requests  Two request response formats : Atompub & JSON

ODATA BASICS
OData is composed of feeds, which are collections of typed entries.  Each entry represents a structured record with a key.  Entries can be part of type hierarchy  Example : http://services.odata.org/OData/OData.svc/Pr oducts

SERVICE DOCUMENT
OData service may contain one or more feeds.  Service document lists all top level feeds.  Sample Service Document : http://services.odata.org/OData/OData.svc  OData service can expose service specific operations

SERVICE META DOCUMENT
Service meta document describes the shape of an OData service.  Describes the Entity Data Model (EDM) of a given service.  Abstract data model of the resources exposed by the service.  Sample Meta Document : http://services.odata.org/OData/OData.svc/$ metadata

ENTITY DATA MODEL
EDM is the abstract data model used by the OData Services.  EDM is independent of underlying data persistence format or implementation.  Entities and Associations are main concepts in EDM.

URI COMPONENTS

http://services.odata.org/OData/OData.svc/Categories http://services.odata.org/OData/OData.svc/Categories(1) http://services.odata.org/OData/OData.svc/Categories(1)/Name http://services.odata.org/OData/OData.svc/Categories(1)/Products http://services.odata.org/OData/OData.svc/Categories(1)/Products/$count http://services.odata.org/OData/OData.svc/Categories(1)/Products(1)/Supplie r/Address/City http://services.odata.org/OData/OData.svc/Categories(1)/Products(1)/Supplie r/Address/City/$value http://services.odata.org/OData/OData.svc/Categories(1)/$links/Products

SERVICE OPERATIONS
OData services can expose service operations, which are simple functions.  A service operation can accept primitive type input parameters.  Can be defined to return a single or collection of primitive, complex type, entries or void.  http://services.odata.org/OData/OData.svc/Pr oductsByColor?color=%27red%27

QUERY STRING OPTIONS
System Query Options ($orderby, $top, $skip, $filter, $select)  Expand query option ($expand). Eager Loading  http://services.odata.org/OData/OData.svc/Ca tegories?$expand=Products  http://services.odata.org/OData/OData.svc/Pr oducts?$select=Price,Name

ODATA OPERATIONS

WCF DATA SERVICE
WCF Data services enables the creation and consumption of OData services for the web.  Demo with VS2010, ADO.NET Entity Model, Northwind DB and WCF Data Service.

SERVER PAGING IN DATA SERVICES
Allow the service author to limit the size of response to a query.  For queries that exceeds size limit:

 Partial

response is returned without exceeding the size limit.  In addition a link to get the rest of the results.

SERVER PAGING

SHAREPOINT & ODATA
Every Sharepoint 2010 server is Data Services server.  Supports ATOM & JSON formats.  Enables client integration with sharepoint from any platform & any language.

CUSTOM DATA SERVICE PROVIDER
Data services sits on top of Data service provider.  Entity Framework  LINQ to SQL DataContext  Custom Service Provider – IDataService Metadata, Query, Update, Paging, Stream Provider  For more details on custom DSP see here

GDATA
Google has GData protocol for accessing Calendar, Youtube.  Limited only to Google Services.  OData is an attempt to open up server side of the protocol.

CONCLUSION
Simple, Uniform way of sharing data at the protocol level.  Enables broad integration across products and breaks data silos.  All you need is Http stack to integrate with any OData producer.  Sharepoint and Office betting on OData.

REFERENCES
http://www.odata.org  http://www.odataprimer.com