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.
Click gear icon to define NXSD schema as per required JSON data.
Finish the wizard as shown below to create NXSD.
Create BPEL variable varJson of NXSD complex type as shown below.
Create XSLT transformation to transform the input variable to varJson. For simplicity, we considered the NXSD structure almost similar to inputVariable.
Now modify Translate activity by giving required values for all other fields.
Click OK. Now our BPEL process should look like below.
Deploy the composite and test to observe the following 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.
Now in BPEL process, create invoke activity to invoke the file adapter.
Now create XSLT to transform inputVariable to inputFileWrite.
Now deploy composite again and test using same input as above. Now we will observe an output file in directory D as shown below.
You can find a sample project here having both of the cases discussed above.
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.
This has been fixed long back , contact customer support.
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.
I too will check thanks for the information now 12.2.1.3 released so will check with that directly
No fix till now, I am facing slimier issue
seems to be yes. Think have to go through oracle support.
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
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
Thanks for your information Rakesh.
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
What’s the SOA version you are using..12.1.3? it seems to be its fixed in later releases but i am trying to confirm in version 12.2.1.2
I am using version 12.2.1.
I will be great if you can further information on this. Thanks again!
Hi,
I am also using 12.2.1 and still getting the error. please let me know how can i rectify.
Thanks in advance !!
Hi
Not fixed yet.
It is also giving me binary content in version 12.2.1.4.