Sample project to show integration of Spring Boot with Apache Olingo to create OData V4.01 API
- maven
- Java JDK 1.8
Execute the following command from the project folder
mvn spring-boot:run
Open browser and try the following URLs,
http://localhost:8080/OData/V1.0/
The expected result is the Service Document which displays our EntityContainerInfo
<app:service xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:metadata="http://docs.oasis-open.org/odata/ns/metadata" metadata:context="$metadata">
<app:workspace>
<atom:title>OData.Demo.Container</atom:title>
<app:collection href="Products" metadata:name="Products">
<atom:title>Products</atom:title>
</app:collection>
</app:workspace>
</app:service>
http://localhost:8080/OData/V1.0/$metadata
The expected result is the Metadata Document that displays our Schema, EntityType, EntityContainer and EntitySet
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
<edmx:DataServices>
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="OData.Demo">
<EntityType Name="Product">
<Key>
<PropertyRef Name="ID"/>
</Key>
<Property Name="ID" Type="Edm.Int32"/>
<Property Name="Name" Type="Edm.String"/>
<Property Name="Description" Type="Edm.String"/>
</EntityType>
<EntityContainer Name="Container">
<EntitySet Name="Products" EntityType="OData.Demo.Product"/>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
http://localhost:8080/OData/V1.0/Products?$format=JSON
The expected result is the hardcoded list of product entries, which we have coded in our processor implementation
{
"@odata.context": "$metadata#Products",
"value": [
{
"ID": 1,
"Name": "Notebook Basic 15",
"Description": "Notebook Basic, 1.7GHz - 15 XGA - 1024MB DDR2 SDRAM - 40GB"
},
{
"ID": 2,
"Name": "1UMTS PDA",
"Description": "Ultrafast 3G UMTS/HSDPA Pocket PC, supports GSM network"
},
{
"ID": 3,
"Name": "Ergo Screen",
"Description": "19 Optimum Resolution 1024 x 768 @ 85Hz, resolution 1280 x 960"
}
]
}
- Official Apache Olingo tutorial section
- Rohit Ghatol's repository