Skip to Content
Author's profile photo Former Member

Consuming Employee Central OData Services with the Java Olingo library

1. Introduction

This article is the third and last in a three-part series. In this blog, I will briefly explain how to consume OData with the OData4j library. You can find the full source  code in the first article of this serie: Consuming Employee Central OData Services with Java

If you want to learn more about consuming OData with the Java OData4j library see: Consuming Employee Central OData Services with the Java OData4j library

2. Olingo

Apache Olingo is an open source Java library which implements OData. It is part of the technical foundation of SAP Gateway technology. You can use Olingo for Client or Server usage. For more information, see:

The steps to consume OData in Java are as follows:

1. Download the metadata and define connection

2. Read Feed

3. Analyze data and parse it to the output

This code snippet shows the Olingo method readEdm which reads the metadata of the given service URL.


With help of metadata being made available via class EDM you can now read a feed which is done in the following code snippet. In this code snippet the final access URL is created by adding filter, select and expand.

read feed.PNG

With the absolute URI you can initialize an input stream. This process includes the basic authentication and http status code checkup.


The next step is to analyze the feed. The method isEmpty controls that the feed is not empty. After that you loop over the entries.

fetch data.PNG

The method parseData initializes the parse process by looping over the properties of each entry.

parse Data.PNG

The method handleEntry writes the name and value of attribute in the data model. If the attribute is empty the method writes the String “null” as value. If the entry has <<PerPerson>> as entity, a specified handleEntry is launched.

handle entry.PNG

This was the last blog in my three-part series. I hope you enjoyed it. If you have further questions please do not hesitate to contact me!

Best Regards,


Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi Jonas,

      I can't find the source code for this tutorial, it said the page is not longer available. could you please upload the source code into github ?