Monday, January 26, 2015

How To Add New Operation in Oracle Mobile Suite Service Bus REST Service

I will use sample app from my previous blog post as the basis - Oracle Mobile Suite Service Bus REST and ADF BC SOAP. I was describing there the main steps in defining transformation from SOAP WS based on ADF BC to the REST WS interface. I will dive a little bit deeper into the same topic and will explain how to add new operation to the REST WS interface.

Here you can download updated sample application - MobileServiceBusApp_v2.zip. In order to add new operation to the REST interface, you should choose Edit REST option for REST Proxy Service in JDEV Service Bus project:


REST Binding editor will appear. Here you should define new resource - I will add /employees to return the list of all employees. New operation should be defined for resource path - /employees, operation getEmployeesListAll in my case:


You can give any meaningful name for the operation. Make sure to select correct resource path and use GET (if you want to fetch data, not update or delete). I'm getting the list of all employees, this means there will be no parameters in this case:


In the response specification tab for the getEmployeesListAll operation, make sure select JSON as the payload. You could use the option to generate sample payload - this shows what kind of result set will be constructed (based on the response XSD - HRRestProxy.xsd, I have created it in the previous post mentioned above):


Once new operation is defined in the REST wizard, we can add it to the mapping. Simply you could copy existing operation mapping to the newly created operation branch. Select new branch and provide required operation name - getEmployeesListAll in this case:


We need to edit request action first and specify empty payload - we want to fetch the list of all employees. For this we could reuse existing transformation file (REST to SOAP):


Important to remember - transformation file is created as a XQuery Map module, where you need to specify source and target types (this will allow to transform REST to SOAP and vice versa):


Request action contains empty value binding - REST variable will be initialised as empty, this will allow to use getEmployeesListAll operation with /employees path:


For response action I'm reusing the same transformation as in getEmployeeList operation - response will be parsed in the same way, using the same binding:


This is how it works - the list of all employees is fetched with /employees path (testing using Postman extension available in Google Chrome):


Previously implemented operation works as well, user could search by First Name/Last Name:

No comments:

Post a Comment