Skip to main content

OData

What Is OData?

OData is an open standard for building and consuming RESTful APIs. It defines a query language to send and retrieve data via HTTP and to perform operations on data.

There are two widely used versions of the protocol: OData v2 and more extended and functional OData v4. The SAP Cloud SDK for Java supports both of these protocol versions.

How does the SAP Cloud SDK support OData?

The SAP Cloud SDK provides powerful APIs and tooling to consume OData services:

  • OData Generator
    • A generator that transforms your service metadata into a type-safe Java client library.
    • The generated client gives you programatic access to all the entities, fields and structures of the OData service.
    • Available as Maven Plugin, also executable from the command line.
  • OData APIs
    • OData v2 and OData v4 APIs to build OData requests with the client libraries generated by the generator.
    • The APIs make it easy to build queries with filters, select clauses, and other OData-specific features.
    • And they integrate with the SAP Cloud SDK's connectivity and authentication features, so you can directly execute your requests using destinations.
  • Generic OData Client
    • If the capabilities of a generated client library are not sufficient, you can use our generic OData client.

How to get started?

  1. Get the EDMX metadata file for your OData service.
    • You can usually find it at http(s)://<service-path>/$metadata.
    • For SAP products you can find the metadata of most services on SAP Business Accelerator Hub.
  2. Generate a client library for your service using the OData Generator.
  3. Use the generated client library to build OData requests.
    • Check the documentation for OData v2 and OData v4 respectively for more information on how to build requests.

You Are Extending an SAP Product or Service, Building a Middle-Ware, Publishing a Cloud App

  • Type-safe consumption of OData services. By consumption, we mean building and executing API calls against OData service with serialized request data and processing serialized responses. All in a type-safe way. Your code focuses on business logic and leaves lower-level tasks to the SAP Cloud SDK.
  • Converting OData API into a different flavor of REST API. You can use the SAP Cloud SDK for Java to build an app that converts your desired REST format to OData calls and vice versa. Such an app may serve as a proxy, integration adapter, service gateway, etc.
  • Serving as a layer to fetch data from and push data to OData services. Instead of building your query tool you can fetch the data with the SAP Cloud SDK and pass it on to your UX framework, analytics tool, data converter, etc. Reverse data flow will allow you to push new or modified data to the OData service for processing or persistence. In that manner, the SAP Cloud SDK can help you implement adapters for a hexagonal architecture.

Developing and Publishing OData Service

  • Use the SAP Cloud SDK to create a robust automated testing framework. You can create a type-safe client for your own OData service with our generator and scale your automated testing capabilities. This comes with the advantage of updating your client code with ease while your service grows and its metadata evolves.
  • Shipping your client module with the SAP Cloud SDK for Java. As a service developer, you're usually interested in an easy way for your customers to consume your service. That's exactly what the SAP Cloud SDK does. When your service is finished, you can generate an API client with the SAP Cloud SDK and release it to developers using your service. As an SAP service, you can contribute your API definition via our contribution process. Once accepted, your pregenerated type-safe client will be shipping as a Maven module of the SAP Cloud SDK.

Coding Convention and Inter-Operability

  • Making sure different teams in your organization coherently consume OData services. The SAP Cloud SDK will help you to save developers' time, ensure best coding practices, and knowledge sharing. Such an approach ensures you won't have duplication of work to save the same problem by different teams and guaranteed high levels of interoperability and integration.

Advanced Features and Custom Development

  • Using certain SAP Cloud SDK features for Custom OData service consumption or publishing. If the SAP Cloud SDK's features for OData consumption do not cover your use-case end-to-end, you can still benefit from our public utility and helper methods like OData expression builder, non-type safe request builders, and some others. Make sure you know what you're doing because the SAP Cloud SDK can't guarantee convenience and correctness in such a case.