Using Translate activity for XML to JSON

In this post, we will discuss about using Translate activity for converting XML to JSON. This is one of the functionalities I wanted to try since release of 12c as nxsd has been enhanced to handle JSON as well. So I tried this using BPEL in both 12.1.3 and 12.2.1 but found to be not working as expected. Hence I will just mention about approach to use Translate activity. And will show you how its working with File Adapter.

Create a BPEL process and drag Translate activity.

translate

trbpel

Click gear icon to define NXSD schema as per required JSON data.

native

Finish the wizard as shown below to create NXSD.

step1

step2

step3

step4

finish

Create BPEL variable varJson of NXSD complex type as shown below.

varjson

Create XSLT transformation to transform the input variable to varJson. For simplicity, we considered the NXSD structure almost similar to inputVariable.

xform

xform1

Now modify Translate activity by giving required values for all other fields.

translate2

Click OK. Now our BPEL process should look like below.

bpel

Deploy the composite and test to observe the following error.

input

error

Note: Please note that the issue has been fixed in latest releases of SOA suite as observed by readers.

However, the same XML to JSON translation is working as expected with File Adapter. Create file adapter using below screenshots using Write operation.

filestep1

filestep2

filestep3

filestep4

filestep5

filestep6

Now in BPEL process, create invoke activity to invoke the file adapter.

invokefilewrite

composite

Now create XSLT to transform inputVariable to inputFileWrite.

xformtofile

xform

Now deploy composite again and test using same input as above. Now  we will observe an output file in directory D as shown below.

ddir

json

You can find a sample project here having both of the cases discussed above.

Advertisement

14 Responses to “Using Translate activity for XML to JSON”


  1. 1 Nagaraj S Rao November 1, 2020 at 3:30 AM

    Hello,

    The Payload mentioned above has Order , Order Lines . I have a similar situation where if there are multiple Order Lines and upon passing the JSON Payload to the BPEL Process, the Receive activity only has the last Order line and the other Order lines are lost. Any pointers on the reason for this behavior.

  2. 2 Anonymous December 26, 2017 at 12:34 PM

    This has been fixed long back , contact customer support.

  3. 3 Anonymous October 4, 2017 at 12:18 PM

    Thanks for the detailed post. I also ran into this issue and then Oracle provided a patch for 12.2.1.0; but I noticed that this issue is fixed in 12.2.1.2 version.

  4. 5 sandeep July 5, 2017 at 2:41 PM

    No fix till now, I am facing slimier issue

  5. 7 Rakesh November 23, 2016 at 8:15 PM

    Hi,

    I am facing he same issue while trying to convert from XML to JSON.

    By any chance did you figure out whats wrong?

    Thanks

    Rakesh

    • 8 Rakesh November 23, 2016 at 11:38 PM

      Just to let you know that I have tried in 12.2.1 and it doesn’t look fixed.

      I found a patch for a similar issue but it was for 12.1.3, tried to apply in 12.2.1 but it wont apply as 12.2.1 is higher version.

      Thanks

  6. 10 Vinod November 23, 2016 at 5:23 PM

    Hi Siva,

    Thanks for the details on this.

    Is this issue fixed by Oracle?

    I am currently using nxsdTranslate to convert XML to JSON but the output is coming as binary content. Do you have any information on this?

    You inputs are really appreciated.

    -Vinod


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.




Pages

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 379 other subscribers

Enter your email address to follow this blog and receive notifications of new posts by email.


%d bloggers like this: