Consume JSON based OData Service using SOA 12c

Please refer Consume OData using SOA 11g post for SOA 11g version.

As part of this post, we will see how to consume JSON based OData Service using SOA 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.

Public OData Services

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

URI Notations

Let us create a SOA 12c composite to  consume the service for the following scenarios.

Following are the URI notations for

  • List All Categories in JSON Format
Consume ODATA JSON using SOA 12c$format=json
  • Filter and display Categories
Consume ODATA JSON using SOA 12c$format=json&&$filter=Name+eq+’Food’
  • Display Category by Primary Key
ODATA JSON using SOA 12c$format=json

Consume using REST Adapter

Let us create a SOA Application. Add a REST adapter to refer to Public ODATA Service.

  • Add a Reference
REST Reference
Add a REST Reference
  • Configure Base URI as
Configure Base URI
Base URI –
  • Configure Resource for Categories
REST Reference
Configure Resource – Categories
  • Add Method and query parameters
Add Method
Add Method and Query Parameters —
getCategories, $format, $filter
  • Configured Reference Details
Configured Reference Details
Configured Reference Details

For the sake of simplicity, let us hard code values for OData Service Parameters like format and filter, inside the composite. Create BPEL Component (Synchronous, default values for rest of options).

Create BPEL Component
Create BPEL Component

Wire BPEL Component to OData Reference.

Inside BPEL, add variables for Input and Output

Add Variables
Add Variables

Add an invoke activity to ODATA Partner link.

Configure Invoke
Configure Invoke

Add an assign activity before the reply activity to copy from OData Service output to Output variable

Copy Rule

Test Scenario 1 – List all categories in JSON Format. 

Configure “Properties” in invoke to add value for “$format”. Providing value ‘json’ will make ODATA service to return data in JSON format. Otherwise it will return in Atom Format. Refer “URI Notations” section for the format of URIs.

Configure JSON Format
Configure Format — Put value as ‘json’

Deploy and test the composite. As values are hard coded inside BPEL, give random string for composite input during testing.  Composite should list all categories in JSON format.

Test Scenario 1 Results
Test Scenario 1 Results

Test Scenario 2 – Filter Categories with Name as Food.

Let us modify the composite to filter the results using $filter query parameter.  Let us get Category with “Name” as Food”.  “Name” is one of the property of “Category”. ODATA URI Notation for this scenario is

http://<base-uri>/Categories?$format=json&&$filter=Name eq 'Food'

Edit Invoke Activity to specify value for “$filter” query parameter

Configure Filter - "Name eq 'Food'"
Configure Filter – “Name eq ‘Food'”

Deploy and test the composite. Result should show Category with Name “Food”.

Test Scenario2 Results
Test Scenario2 Results

Test Scenario 3 – Display Category using Primary Key

OData Protocol allows to list entities by primary key values using the notation


“ID” field is the primary key in “Categories” entity. To list Category refered by ID 1, URI notation is$format=json

To be able to query using this format , we need to build the URI dynamically and assign it to “rest.binding.requestURI” property of Invoke activity.

Already Configured “query” parameters will be ignored and only value of “rest.binding.requestURI” will be executed against REST Service. In our case, $format is needed. So, we will add it as part of the value that is assigned to “rest.binding.requestURI”  property.

Configure URI Property
Configure URI Property

Deploy and test the composite. Category with ID=1 will be shown in the result.

Test Scenario3 Results
Test Scenario3 Results

With SOA 12c’s REST adapter we should be able to call OData Services successfully. If there is  any use case for which REST adapter is not compatible, we can consider using Java Libraries for OData listed in Java Libraries for OData . Please refer  this post  which shows  usage of  OData4j library in SOA 11g environment.

15 thoughts on “Consume JSON based OData Service using SOA 12c

  1. hello,
    could you please tell me the version of SOA you are using? I’m using 12.1.3 and have trouble setting the query parameters with $expand . It is throwing XML validation error as $ is not accepted for XML element names. Could you please advise on this issue?
    Appreciate if you could share some sample code.
    Maneesha M

    1. It was with 12.2.1. Are you getting same kind of screens in 12.1.3?. If I could find the sample project , I will send it to your email.

    2. Hi Maneesha,
      I’m also unable to resolve the issue in 12.1.3 with query string parameter containing a $ in the name. Did you find a workaround or did you use 12.2.1?

      Thank you.


  2. Hi Krishna,

    I followed same steps for PUT operation in 12.2.1 oracle vm.
    Request is getting submitted properly to the target system and data is being updated but I am getting “501 not implemented” error in BPEL where I am invoking this service.
    any pointers to tackle this situation.

    – Harshal

    1. Hi Harshal
      Based on the error, 501, I guess “PUT” method is not implemented on the target system . Please try different target system which supports PUT method.

  3. Hi Krishna,

    I am using OSB version and trouble setting the query parameters with $.
    Rest Adapter wizard doesn’t show RunTime Properties

    Is there any patch required or any steps needs to be followed to make this property visible.


    1. The blog is about SOA and not OSB. Although you design this in the same JDeveloper, the options for SOA are different than OSB Rest Reference!

  4. It is quite interesting that Warren Buffet owns 10% with the Chinese Greely electric
    and hybrid car company, and he is attempting to purchase really it.
    Some with the drawbacks of those systems is that it isn’t necessarily dependable.

    Around $117 billion was committed to projects emphasizing alternative energy like wind,
    biofuel, solar and geothermal.

Leave a Reply to GOD Cancel reply

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