Invoking REST Service
API from SOA Suite 11g via Spring Context
Requirements:
a)
Oracle SOA Suite 11g (If you gonna use SOA Suite
12c, then this post is not useful, as 12c have implemented REST Adapters for
JSON based REST API Invocation)
b)
JDeveloper 11g
Steps:
1)
Open JDeveloper Application
2)
Select Tools -> Check for Updates -> Click
Next -> Select all the checkboxes -> locate “SOA Composite Editor” and
Install
3)
Select Tools -> Check for Updates -> Click
Next -> Select all the checkboxes -> locate “Spring, Weblogic SCA
Integration Extension” and Install
4)
Select File -> New -> Under General,
Applications -> SOA Application -> Enter Application Name and Click Next
5)
Enter the Project Name, select Java & XML
from Available to Selected and Click Next
6)
Enter the Composite Name, select Empty Composite
and Click Finish.
7)
Open <Composite Name>.xml, select Design
Tab
8)
In Component Palette, From Service Component
section, click & drag BPEL Process into composite.xml
9)
It creates a client & a simple BPEL Workflow
10)
In
Component Palette, From Service Component section, click & drag Spring
Context into composite.xml
11)
Now we need to create Spring Bean for
integrating Spring into BPEL Workflow
12)
Create a Java Interface and define methods
13)
Create a Java Class which implements the above
created Interface and implement your logic
14)
Register the bean into Spring.xml configuration file
as below,
<bean class="<fully
qualified class name>" id="impl" />
<sca:service
name="test" target="impl" type="<fully qualified
interface name>" />
15)
In composite.xml, Connect the BPEL Component
& Spring Component, necessary files (wsdl, componentType) will be generated
by JDeveloper
16)
Now you can use the Spring Component inside BPEL
Workflow, as needed you can invoke this Spring Component via Invoke activity
with proper input & output variables assigned.
17)
In the Spring Implementation Class, you can play
around with all capabilities of Java. As mentioned in the Topic, I’ve used it
for Invoking a REST API by constructing a Jersey Client.
18)
Import necessary libraries by, Right-click Project
-> Project Properties -> Libraries & Classpath -> Click Add
Jar/Directory -> locate and import libraries
19)
There are two ways to deploy the artifacts into
WebLogic App Server, post completion of development. Direct Deployment or export
the application as SOA archive and deploy it via Enterprise Manager Console.
I have
used Jersey 2.6 as SOA 11g supported by jdk6.
Jersey 2.6 API Dependency List,
If needed, i can share the sample code.

