When the web service response comes dynamically for every request made, certain fields can be populated dynamically because of which response mapping cannot be done completely via mapping tool. Only static fields can be mapped using mapping editor and the dynamic fields can be mapped via custom scripts.
Steps from Design Time tool
- Create an OData Service Implementation Project
- Create an OData Model for an operation
3. Right click on odatasvc and choose Select data source
4. Select the entity set and choose the query CRUD operation. Select the data source SOAP Service.
5. Specify the wsdl file and choose the operation from the list of soap operations and click on finish
6. Right click on Query and Select Define ResponseMapping
7. Map all the static fields as below
Here the fields under businessKeys property are populated only after a query request is fired. So, these dynamic fields are mapped via scripts
8. Right click on Query and select Define Custom Code
9. Get the entire response from message body, extract the dynamic field values and create a list of hashMaps as below. Set this list to custom header
10. From the previously set header get the list of hashmaps and from the message body get the list of hashmaps for all static fields which were mapped using mapping editor, combine them into a single list of hashMaps as below
11. Right Click on Project and select Generate and Deploy Integration Content. This will deploy the bundle.
Now fire an OData Request https://localhost:8083/gateway/odata/SAP/SAMPLE;v=1/QuerySet on the browser.