Soa 12.2.1 New Feature – End to End JSON and Javascript Example

SOA 12.2.1 provides support for end-to-end JSON and Javascript. We don’t have do internal mapping between XML and JSON as in 12.1.3.

As part of this post, let us implement a simple REST service to demonstrate this new feature – End to End JSON with Javascript.

Let us create a very simple SOA Composite which exposes a JSON based REST interface, manipulates the values using Javascript and calls an external JSON based service.


End to End JSON with Javascript
Rest Service

External JSON Service Setup

For external JSON based REST service let us use a  dummy JSON Server.

Start Json Server
Start Json Server

Content of db.json file.

 "posts": [
 "id": 1,
 "title": "SOA Composite Sensor",
 "author": "Krishna Hanumantharao"
 "title": "OSB Result Cache",
 "author": "Girish Patel",
 "id": 2
 "comments": [
 "id": 1,
 "body": "some comment",
 "postId": 1
 "profile": {
 "name": "Krishna"

Result of get query from the REST service

Output from REST GET Query
Output from REST GET Query

Create Reference

With the dummy REST service setup, let us create SOA Application and create a reference to external REST service. Drag and drop a “REST” adapter to reference section.

Create External Reference
Create External Reference

Configure Resources

Create Resource
Create Resource

Create Method Reference with highlighted values for GET. Specify parameter name as “id”.

Create Method Reference for Get
Create Method Reference for Get

Create Method Reference with highlighted values for POST.

Create Method for Post
Create Method Reference for Post

Screen with configured details. Click “Finish” to create the reference.

Reference Configuration
Resources Configuration

Create Service Entry

Drag and drop a “REST” adapter to service section. Configure to have following values.

While doing  GET method configuration, create  a “parameter” with name “id”.

Service Entry Configuration
Service Entry Configuration

Create BPEL Component

Drag and drop a BPEL component and configure with highlighted value.

Create BPEL Component
Create BPEL Component

click on plus sign to add REST methods. Add both the methods available in service entry wadl.

BPEL Interface Get metho
BPEL Interface getPost  method
BPEL Interface REST Methods
BPEL Interface Methods

Wire the BPEL component to External reference. As we have two methods, created BPEL component will have pick activity.

BPEL Pick Activity
Created BPEL

Create five variables.

Create Variables
Create Variables

Click on OnMessage in “getPost” branch. Copy the user passed value, available in “” to “id” variable. -> variable defined during creation of REST service entry interface.

Capture Input Value
Capture Input Value

Add an Invoke activity in each branch. Configure Invoke for “getPost” interface

Configure Get Input
Configure Get Input

As part of configuration, pass the value passed by user, stored in “id” var  to “” variable.

Set value for REST Query Param
Set value for REST Query Param ->variable defined during creation of external REST service reference

Add a assign activity after the invoke. Output of external REST service will be available in GET_OP variable. Copy the value to Output variable of our REST Service.

Assign Output
Assign Output

This completes the “GET” branch.


Similarly configure Invoke for “doPost” interface

Configure Post Input
Configure Post Input

For “POST”, let us define the input of our REST service to be the following. Here name is split into firstname and lastname. We will concatenate and pass it as single name to the external REST Service.

id: 3,
firstname: "Ken",
lastname: "Ben",
title: "Introduction to Coherence"

Add an assign activity below receive . Add copy rules to copy

id -> id

concat(firstname, lastname) -> author

title ->title

Set Variables for POST - REST Query
Set Variables for POST

That completes POST branch.

Now, let us deploy and test it.

Test GET interface

Give the value of “1” or “2”. We should get details of record for that id in JSON format.

REST Get Results
REST Get Results

Test POST interface

Let us give following value. POST will add a new record .

"id": 3,
"firstname": "Ken",
"lastname": "Ben",
"title": "Introduction to Coherence"

After testing with the above input ,verify the result by invoking “GET” to see the newly added record

End to End JSON with Javascript
Newly Added Record

This completes the creation and testing  of a very simple SOA Composite which exposes a JSON based REST interface, manipulates the values using Javascript and calls an external JSON based service.

Please refer “Using Javascript and JSON in BPEL Component” for more information on using Javascript.



12 thoughts on “Soa 12.2.1 New Feature – End to End JSON and Javascript Example

  1. hey can you tell where are you defining the input for the POST that json you mentioned, where exactly in the composite we have to put it?

    1. Do you mean the following POST input?.

      id: 3,
      firstname: “Ken”,
      lastname: “Ben”,
      title: “Introduction to Coherence”

      It doesn’t need to be defined in the composite. As we have defined the input and output parameters to be JSON object, we can pass any valid JSON object. The above JSON needs to be used while testing.

      1. but when you are making assignments, it has to be somewhere in receive and response from where i can make the mappings.

        like you are making assignments with in the picture above how can i have the elements pf id, full name etc without specifying the input json.

        1. I am not sure whether you are asking where specifically, “id”, “first name”, etc are defined.
          Unlike XML, we are not using a JSON schema which defines all the elements. When you create a service entity, you will see variables of type JSON object are created.

          In this case , for POST, a variable called RestSvc_doPost_InputVar , of type JSON Object is created. In this blog, we are making an assumption that Input JSON will have fields like “id”, “firstname”, “lastname” etc and we accordingly access those inside bpel as , process.RestSvc_doPost_Inputvar.fullname,etc.

          The external rest service, has fields like id, author and title as part of the JSON object. There is no specific definition for id, author, title inside soa composite. We set values to those using the,, etc.

          Unfortunately , I dont have the sample project. Try creating the project and if you get an error , send me the project.

          1. hi thanks for the reply,
            I am not getting an error, but my issue is i am creating a POST request and i want to specify few child elements for it using JSON, so how can i specify them, like you specified id fname, lname etc.

          2. You can define your own JSON object with field you like. For example, this is another JSON with different fields.

            BookId: 3,
            AuthorName: “Ken”,
            AuthorLastName: “Ben”,
            BookTitle: “Introduction to Coherence”,
            AnotherField: “someValue”,
            YetAnotherField: “somevalue”

            While Testing, assuming the above will be passed as input to your service, you can access the passed JSON object in assign activity like

            Hope this helps.

  2. Hi Krishna,

    I have a question on rest string conversion issue which i am going through in my recent project. I am using Jdev version 12.1.3. Client wants us to send null data for one of the json fields in the format “city”:”” . But instead the rest adapter is converting the empty field value to “city”:null . Is there a property in the adapter that i am missing or any way we can manipulate/transform the value as per the requirement using xslt/xquery or java class.


  3. Is it necessary to pass the input parameters in get method ?
    As in my requirement there will be dynamic value changing in the URI-
    Example – http:\\localhost:9091\api\resourcepath\{dynamic_value}*x

    Also how to pass this dynamic value in the URI path while calling Rest adapter as a reference.

  4. First off I would like to say terrific blog!
    I had a quick question that I’d like to ask if you don’t mind.
    I was interested to know how you center yourself and clear your head before writing.
    I’ve had a difficult time clearing my thoughts in getting my thoughts out.
    I truly do enjoy writing but it just seems
    like the first 10 to 15 minutes tend to be wasted simply just trying
    to figure out how to begin. Any suggestions or tips?

  5. The best in class, Depoxito manage to pay for you high-end
    experience that take in hand the look and character of genuine VIP standarts,
    we manage to pay for you the best glamorous to high-level experience of VIPs expect
    in any top end casino, grand alive casino royale
    pay for you the new studio design element including the grand blackjack, offering our VIP Customer the best experience of a Salon privee table.

    New style table in addition to feature across the room like grand roulette upgraded on our provider playtechs mini prestige roulette which
    delivering more interesting and richer playing experience.
    The further experience contains a sum of seven tables including five blackjack tables, one
    roulette table and one baccarat table. Grand stimulate casino royale has been high hand-engineered to fit the needs of our customer to using it, and contains unique elements that is specially expected
    to maximize the impact value we got from our customers and diversify it to the existing network.

    Soon, Depoxito will develop an enlarged authenticity technology upon alive casino for
    our VIP member, these most highly developed technology ever seen in breathing casino including this greater than before reality.
    Which allow players to experience products upon an entire
    supplementary level which is never seen before literally leaping out of the game and
    taking the blackjack, baccarat, roulette and additional game into
    the collection entire level.
    Depoxito VIP Baccarat, we meet the expense of you the entirely exclusive sentient VIP Baccarat
    that is played gone in the works to 7 players at the similar table and our intensely trained pretty stir baccarat dealer.
    And of course our VIP supporter will feel as if they were in point of fact sitting at one of the summit casino baccarat table.
    This immersive gaming experience creates a hugely thrill-seeking announce that our VIP players
    will locate difficult to surpass.
    Here is the list of rouse casino game that depoxito provide,
    we have enough money the widest range of stir casino
    games upon the spread around including : blackjack unlimited,
    blackjack prestige, roulette, baccarat, poker, hi-lo, sic bo, and grand enliven casino royale such as Grand
    Baccarat, Grand Blackjack and Grand Roulette for our VIP member.

    And of course as a advocate of Depoxito you can enjoy every the games that we have enough money to you, every you dependence to accomplish is just visit our site depoxito and register it by yourself takes occurring
    to 3 minutes and next youre satisfactory to produce an effect
    any game that you want.
    Be our VIP, innate our VIP member of course decided you the best assistance you can get from us all you craving to
    be a VIP enthusiast is no question easy. all you dependence is
    just save playing upon our site, accrual and conduct yourself once a VIP later the
    amount that our company had written, keep playing and our customer benefits will
    log on you that you are promoted to become a VIP zealot on our site.

Leave a Reply

Your email address will not be published. Required fields are marked *