By Mohankumar Panneerselvam
OData is a web protocol for querying and updating data. REST is an architecture style, whereas OData is a specific implementation of REST designed to generate and consume data, which supports two formats: AtomPub and JSON.
The OData standard is well suited for web service applications that require an interface for exposing CRUD operations on a tabular data model to clients. OData is less suited for applications that are primarily RPC-oriented, or in which data operations are constrained to certain prescribed patterns.
Data sources provide various approaches to access their data. For a couple examples, a database can queried using JDBC or a webservice can be consumed using SOAP/JSON. But if we define a common data model and protocol, the service implementation can be consumed by various web/mobile clients. In a sense, OData is the Uber of protocols.
How OData works:
The OData data model provides a generic way to organize and describe data using Entity Data Model(EDM).
OData protocol lets the client request and get a response from an OData service. This protocol is a set of REST interactions (i.e. CRUD) along with OData query language.
OData client library provides the interface to access OData using the OData protocol. These client libraries are optional, as the underlying protocol uses HTTP.
OData Service provides the exposes an endpoint for the data. This service implements OData protocol and uses the OData data model to translate data between the request and the underlying data source.
What OData is not
OData was not created to standardize web services. OData collections use a RESTful API to share their data resources, but OData is not attempting to become “one standard to rule them all.”
What operations OData supports
- GET: Reads data from one or more entities.
- PUT: Updates an existing entity, replacing all of its properties.
- MERGE: Updates an existing entity, but replaces only specified properties.
- POST: Creates a new entity.
- DELETE: Removes an entity.
What’s the relevance of OData to Salesforce.com
Force.com will be introducing a new feature called External Data Source/ External Object to integrate external data without the need to sync it to the platform. This will eliminate the need to build a custom callout to invoke, parse, map and error handle with external data provider using SOAP/HTTP.
External Data Source:
Define the connection to external data source using one of following options
- Apex connector framework
Using the meta data model (EDM) exposed by OData service, the platform can created a custom object & fields. This object will have an extension __x which is differentiated from custom object __c. This object can be used like any other object in VF page/tab etc.
These are the few use cases where OData can be used in Salesforce:
- Order status.
- Shipment Status.