Advertisements



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

This seems to be a bug as I observed same error in which ever way I tried. So if any readers tried this and able to get it right please do let me know.

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.

Advertisements

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


  1. 1 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.

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

    No fix till now, I am facing slimier issue

  3. 5 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

    • 6 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

  4. 8 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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s




Advertisements

Pages

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

Join 349 other followers

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