Calling RESTful services in Oracle SOA Suite
SOA Suite 11g
In recent history (SOA Suite 11g) there were no out of the box options to integrate with or expose RESTful services. Also there were no out of the box options to handle JSON payloads. Since Oracle SOA Suite has many options for integration with Java code, there are several workarounds such as using the SocketAdapter (http://javaoraclesoa.blogspot.nl/2012/12/receiving-json-requests-in-oracle-bpel.html) or using the Spring component (http://technology.amis.nl/2009/12/16/soa-suite-11g-using-spring-component-to-mimic-http-binding-and-integrate-restful-services/). These workarounds however all have major drawbacks and it is difficult to set them up in such a way that they are flexible and the code is maintainable.
SOA Suite 12c
SOA Suite 12c introduces the REST adapter to make life a lot easier.
|A picture of the technology adapters in Oracle SOA Suite 12c|
The REST Adapter can be configured in 2 ways. Manually or by means of a WADL (Web Application Definition Language). The manual definition will not be described in detail since the result should be the same as is done by means of a WADL. This also nicely illustrates that using a WADL is preferable.
Using a WADL
A WADL for REST services can be compared to a WSDL for SOAP services. As with SOAP services, using a predefined definition file makes the configuration easier. This is especially true when calling REST services. Some frameworks provide out of the box WADL's such as JAX-RS (see for a simple implementation example; http://javaoraclesoa.blogspot.nl/2014/05/what-is-rest.html). If a WADL is available, use it. It is more likely more complete then what you can create yourself. When there is no WADL available, a third party tool can be used to generate a WADL. Smartbear SOAP UI for example. In SOAP UI you can configure a RESTful service and SOAP UI will generate the corresponding WADL for you for free. 'naam' in the below screenshots is dutch for 'name'.
|Create a new REST project in SOAP UI|
|Create a REST service from an URI|
|After inputting an URI, a request is generated in SOAP UI|
|A WADL is generated.|
The WADL chooser supports URL's to download a WADL from. Also deployed SOA composites or OSB proxies can be selected which provide a RESTful interface. A deployed JAX-RS service however cannot be selected.
|The WADL chooser|
|There were some warnings after parsing the WADL. Nothing fatal. Mostly request/response message definitions missing.|
|The configuration for the binding is generated after reading the WADL|
|An example of a configured JSON response.|
|An example BPEL process in which a REST service is called synchronously.|
|A WADL can be parsed from the Enterprise Manager test console.|
In the above sample I've used a service which obtained it's parameters from a GET request and returned a JSON payload. The JSON payload is converted to XML and can be processed as usual. JSON support is new in SOA Suite 12c. Also several other native formats are supported such as MFL. Message Format Language (MFL) was previously used by the OSB 11g as an alternative to the NXSD used in the rest of the SOA Suite (mainly the file adapter).
|JSON message format is supported and also Message Format Language (part of the OSB in 11g)|
|Generating an NXSD to describe a sample JSON file|
This blog post describes calling a RESTful service with the REST adapter. I have also written an article on exposing a composite with a RESTful interface.