There are some changes made in Rest Adapter from previous Oracle SOA 12.1.3 version, in the new Oracle SOA version 12.2.1 they have removed a predefined request/response schema definition in WADL that we use while configuring rest adapter.
For Building a Rest GET Operation, there are two important ways.
Create params using Templates
We can get them from Inbound → user-metadata
Create params using QueryParameters
We can get them from inbound → query-parameters
Below is the Step By Step process for building a GET Operation for getting a JSON Response using Templates
Create a new Project
Name as “RestProject”
Now we will start creating a Rest Adapter
Name as “sayHello”
Adding a New “Resource path” as /{name}
Creating a New Method
Method: sayHello
Resource:/{name}
HTTP: GET
Now Create a New pipeline
Name as “HelloWorldPipeline”
Map them
DoubleClick on HelloWorldPipeline
Create a pipelinepairNode
Create a new Assign Activity and add below concat operation
---------------------------------------------------------------------------------------
concat('Hello ',$inbound/ctx:transport/ctx:request/tp:user-metadata/@value)
or
If you have more than one template use below xpath
concat('Hello ',$inbound/ctx:transport/ctx:request/tp:user-metadata[@name=’name’]/@value)
---------------------------------------------------------------------------------------
Now, for our scenario we need to send a JSON Response, so we need to create a NXSD to transform XML to JSON.
Create a new NXSD Schema
Add sample response { "Response":"Hello"}
Now In the response stage, insert nXSD Translate activity
In the input of nXSD, past below xml
--------------------------------------------------------------------
<Root-Element xmlns="http://TargetNamespace.com/ServiceName">
<Response>{$AssignRequest}</Response>
</Root-Element>
--------------------------------------------------------------------
Translate: XML to Native
nXSD Schema: xsd location
Output: Content of $body
Testing
good, how will you do the reverse json to xml
ReplyDelete