Posts Tagged 'JSON'

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.



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.

Sending JSON payload requests from BPEL

In this blog post, I am sharing sample code that demonstrates the usage of JSON in BPEL context. The code is refactored into 2 projects containing the java utility code and  a sample BPEL process. The code can be downloaded from here.


Java Utility Code:

  • Using cookies to pass authentication info (username and password).
  • Sending XML payload as URL parameters using intermediate conversion to JSON for GET request.
  • Sending HTTP request through HTTP proxy.
  • Sending JSON or XML payload in the POST request.

BPEL Process:

  • Using BPEL preferences to store any configurable information.
  • Using java embedding activity to call the external java code. The jar file has to be kept in SCA-INF/lib to refer to java code.
  • Using Replay activity. The fault policy mechanism can also be used for retry functionality, if we throw BPEL related faults from java code.
  • Converting JSON to XML and vice-versa using java utility routines in BPEL.
  • An example on creating XSD similar to JSON data format representing the service response so that XPath expressions can be used in BPEL.

Does not cover:

  • HTTP Basic Authentication
  • Using XML APIs (like JAXP) to convert input XML to URL parameters
  • URL encoding while calling HTTP GET method
  • Using JAX-RS to invoke REST based services


  • in the code zip file is taken from Biemond’s blog.
  • The libraries used for JSON processing can be downloaded from here .
  • JSR – 353 Java API for JSON Processing is closed for public review.

The code is uploaded for reference and  this may not be the only way to achieve this.


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

Join 380 other subscribers

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

%d bloggers like this: