OData(Open Data Protocol) is a REST-based protocol. A Protocol will be called REST-based if it fits under certain constraints. Below is the list of constraints.
- Client-Server Architecture – Request from Client to server
- Statelessness – Meaning Request are not stored in the server
- Cachebility – Response is cacheable if define as cacheable
- Layered system – There is no direct connection between client and server for a long way
- Uniform interface – Decouple architecture
- Code on Demand – This is one optional constraint where the server can extend the functionality of the client.
OData was initially released by Microsoft and then later by OASIS.OData is supported majorly used industry-standard request/response format that is JSON & XML. You can get more details on www.odata.org
Let’s jump into the concept of OData service and its service which is widely pronounced in the SAP industries 😉
What is an OData service? -OData service is nothing but a service that allows accessing the data via OData Protocol(HTTP based Restful CRUD Operation)
SAP has provided a demo system to learn about the basic OData service, below is the link to get one demo system access https://blogs.sap.com/2017/12/05/new-sap-gateway-demo-system-available/
Before discussing the OData service, let’s Go through a few terms & keywords Data Model: Data model is nothing but a way of describing data. e.g:
Entity Type: This is nothing but a collection of Names having some property and along with that it is associated with a key. (Think about work area😉) e.g sales order -> having names called order number, order qty, order value, etc. where order number is the key
Entity Set: A collection of entity types can be either 0 or many cardinalities. For example, if a sales order is entity type, then the collection of multiple sales orders is considered an entity set. (Think about internal table 😉)Property: It is associated with the entity type. Just like fields of a table
Navigation Property: This is a special property that holds links to navigate another entity set
Association: The relationship between two entity types is called association Thinks will be more clear on the examples. Structure of the OData service.
- Service Document – This gives you the details about the service entity sets and these details can be get from the service document URL. The format of the service document URL is http://<host>:<port>/sap/opu/odata/IWBEP/<Service Name>
- Service Metadata Document: This gives you the metadata of the service means all the technical level details. The URL format of the service metadata document is http://<host>:<port>/sap/opu/odata/IWBEP/<service name>/$metadata
Don’t worry about the many details about the OData service right now, once we create our own OData service that It will easier for you. Let’s take an example provided by SAP for Demo purposes. Note: These URLs will work only when you log on to the ES5 system. detail link is provided above. SAP Demo OData service name is GWSAMPLE_BASIC. The service document URL https://sapes5.sapdevcenter.com/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/
Let’s check about the service Metadata document by using the below URL https://sapes5.sapdevcenter.com/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/$metadata
Yes, there are some association tags, etc. We will check as and when creating the same in the upcoming blogs series. Please leave comments/suggestions/improvements – it will help me to decide in the upcoming blogs. Thank You