Sunday, January 4, 2015

Oracle Mobile Suite Service Bus REST and ADF BC SOAP

One of the key parts of Oracle Mobile Suite 12c offering is Service Bus product. This is logical choice - Service Bus allows to transform complex SOAP Web Service data into simplified REST format, preferred by mobile client. I think it is essential to use Service Bus, when implementing enterprise mobile applications. It makes sense to learn how Oracle Service Bus works. I would recommend to start from Steven Davelaar excellent tutorial article, available here - Creating a Mobile-Optimized REST API Using Oracle Service Bus – Part 2.

I have created my own ADF BC application with SOAP WS - findEmployees method (filters by first and last name). Here you can download both applications - MobileServiceBusApp_v1.zip. Keep in mind, for some reason Service Bus server doesn't start with JDEV 12c BPM Default Domain, it works only with JDEV 12c SOA Default Domain. Make sure to check, which JDEV you are using, you can check the list features installed:


ADF BC SOAP service is implemented to support Master-Detail (Employee - Department Managed by Employee) structure:


Detail VO is visible in WS response, only when ADF BC SDO classes are generated for the VO:


Here is Service Bus application main diagram. External Services contains a reference to the ADF BC SOAP WS (invoked through HTTP service). Proxy Services contains a reference to the REST proxy (this will be accessed from mobile device). Pipeline contains a mapping resource, this is where transformation between SOAP and REST happens:


REST proxy service is defined to support getEmployeesList operation with parameter - nameVar:


REST proxy service response is configured with EmployeeListResponse element, stored in HRRestProxy.xsd file:


Here is the structure returned by REST proxy service - list of employees and list of departments managed by employee:


Pipeline mapps SOAP and REST services. Here we can define how request and response actions are handled. Request action is processed with mapping stored in EmployeeDetailsPS2BS file:


Request action mapping is simple, it needs to pass search parameter and assign it to nameVar parameter from SOAP WS:


This is how search parameter is initialised in REST -  through special expression, value is taken from REST request and sent to SOAP call through mapping:


Response is handled with EmployeeDetailsBS2PS mapping:


This mapping is more complex and it represents the data, returned by REST proxy service. Here we need to map all attributes from SOAP WS to REST proxy service response. This is the place, where actual transformation happens - here we can decide, how we map attributes and even convert between types:


To test Service Bus application, you can simply right click on REST proxy service and choose run:


Service Bus application should be accessible in Enterprise Manager, list of all operations should be present. In the picture below, we can see both SOAP and REST proxy services present. You can open HRRestService:


Test button is present, this allows to test REST proxy service directly from Enterprise Manager:


Provide search parameter  - it will look for 'w' in both first and last name:


Response is constructed with list of employees:


This is request URL: http://127.0.0.1:7101/MobileSBProject/HRRestService/employees/w, it can be used from mobile client, to retrieve similar data (department managed by employee 200 is present):


No comments: