Thursday, September 4, 2014

REST Service in 12C OSB and SOA

In this blog I would like to explain how to use the  REST Adapter from SOA as well as in OSB in the 12C Release of Oracle SOA Suite

In this exercise a REST service implemented in BPEL acts as provider and OSB will have a REST  client. Both will use the REST Adapter feature.

Step 1: Create an xml schema as follows(RestSchema.xsd)

<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:vrs="http://test.schemas/RESTSchema"
targetNamespace="http://test.schemas/RESTSchema" elementFormDefault="qualified">
<xsd:element name="request">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="message" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

Step2: Create a SOA project in12C Jdev

Step 3: Open the projectname.xml(composite.xml) file  and add a REST Adapter to the exposed Service Section


Step4:  Choose the type as Service. From the operational bindings add Operation Binding

Step5:
In the request tab choose the payload type as XML, JSON or URL_Encoded. Choose the  request element from the RESTschema.xsd for the request type


Step6: In the response tab choose the payload type as XML or JSON. Choose the request element from the RESTSchema.xsd



Step7: Add a mediator and BPEL process and wire them as shown below

Step 8 : Configure the BPEL process as below




Step 9: Map the mediator as shown below
Step10 : Deploy the composite

Step 11: Now create new OSB Project. We can use the same schema in OSB service as well

Add the REST Binding to  External Services section

Step 12 :  Configure the REST Binding as follows. Select the payload type as XML/JSON. Select the request element from the RestSchema.xsd

Step13: On clicking OK it will create a business service as shown below


Step 14 : Deploy the OSB service and test  the business service using the osb test console