Consume OData Services Using Oracle SOA Suite 11g

As part of this post, let us see how to consume OData Services using Oracle SOA Suite 11g. See this post to consume OData Services using SOA Suite 12c.


OData (Open Data Protocol), promoted by Microsoft, now an OASIS Standard,  helps service providers to expose their data using RESTful APIs.  OData supports, exposing of data in two Formats, Atom and JSON. Please refer OData WebSite for information about OData.

Integration using SOA 11g

There was a need to integrate an external OData Service using Oracle SOA 11g. External OData Service (OData Version: V1)  was using Atom Format to expose the data.

Oracle SOA 11g doesn’t have any adapter for accessing OData/Rest services. So,  we were looking for Java Libraries to consume OData Services. At that time of search, only OData4J  was available. Apache Oligno was evolving at that time and we didn’t find much information about it. We decided to go with OData4J library.

For updated information about available Java libraries for OData, please refer Java Libraries for OData . With SOA 12c, we can use REST Adapter to connect with OData services which exposes data using JSON format.

Public OData Services

One of the publicly available OData Service can be accessed at Public OData Service

Let us consume the service to get the list of “Categories”.

Consume OData in SOA
Public OData Service

Development Steps

Add odata4j-0.7.0-clientbundle.jar to SOA Server Classpath or Composite’s SCA-INF/lib directory

Create Custom Java Library (functions to call OData Services) and add to SOA Classpath or SCA-INF/lib directory

 public static String getCategories(String svcURL,String entity) 
 ODataConsumer consumer = ODataConsumers.create(svcURL); 
Enumerable<OEntity> entities=consumer.getEntities(entity).execute(); 
 for(OEntity category: entities) 
 System.out.println("Category Name: "+category.getProperty("Name",String.class)
 //Convert to XML structure using JAXB to manipulate in bpel
 return ConvertToXMLString(entities);

Create a Java Embedded Activity to call “getCategories” functions

CustomODataClient.getCategories("", "Categories");

Use JAXB or equivalent technology to convert between Java object to XML.

 Resultant XML can be manipulated in BPEL for the rest of the business flow.


Output from Standalone Client

Following is the output when executed from a standalone Java Client

Category Name: Food
Category Name: Beverages
Category Name: Electronics 

Leave a Reply

Your email address will not be published. Required fields are marked *