This blog post covers how to expose an OData Service in SAP Cloud Platform Integration with $expand and deepInsert Scenario.
OData Sender Behavior
Below is a sample integration flow with OData Sender.
- OData sender converts the incoming OData Request payload (atom+xml / json) ① to simple XML. ②
- For OData Operations which has response body (create, read), the final step in the IFlow has to be a simple XML which represents the Entities defined in OData sender Edmx. ③
- This final XML is converted back to atom+xml / json to the client. ④
- I used Northwind service edmx to create an OData Service “NorthwindCopy”.
- Choose the entities that you need. I have chosen Category, Customer, Employee, Order, Product, Supplier, Territory.
- Edit the metadata to define the navigation properties for each of the Entities as desired. I have edited the metadata as required and below is the graphical representation of my metadata.
I will configure $expand for EmployeeSet?$expand=Orders,Territories,Orders/Customer
- Bind the Query operation for EmployeeSet.
- The default integration flow will have only the root entity in response mapping.
In this case only EmployeeSet is mapped.
- We need a mapping for $expand with Orders, Territories, Order/Customer. For this, I will use a dummy OData Receiver. (This will be deleted later)
- In the Processing tab of this dummy receiver, open the query wizard by clicking Select in Resource Path.
- Choose Connection Source as Local EDMX File. Choose the OData sender metadata.
- Choose Query operation with the desired sublevel. Choose the fields. In this case, Orders,Territories,Orders/Customer. Click Finish and this will generate the required XSD. Note the name of the XSD created.
- Delete the dummy OData receiver that was created in previous step.
- Similarly, use the query wizard to generate the XSD for the OData Receiver.
- Use this generated XSD in response mapping step.
- Note that the expanded entities are mapped respectively.
- GET call <serviceRoot>/EmployeeSet?$expand=Orders,Territories,Orders/Customer will return expanded entities.
I will configure DeepInsert for Categories -> Products -> Supplier
- Bind the Create operation for Categories.
- The default integration flow will have only the root entity in request mapping.
In this case, only CategorySet is mapped.
- Add a dummy OData receiver to generate the XSD for the sender.
- Open the query wizard, and choose the Sender EDMX. Select Create operation with sub level and choose the entities.
- Delete the dummy OData receiver that was created.
- Similarly, configure the Create operation in Odata receiver with required sub levels.
- Select the created XSD in request mapping.
- Response for deepInsert can contain only the root entity. Hence, there will be no change in response mapping.
- Deepinsert from Postman.