Advertisements

Archive for December, 2015

ADF BC REST Services–III – Using Row Finder

In this post, we will see how to use Row Finder in ADF BC REST services.

Open REST resource VO and create a View Criteria as shown below having 2 bind variables for Department name and Location ID.

vc

vc1

Go to Row Finders section and create new one with searhByDeptName.

rf0

Here we can observe that above VC is selected by default. In Variables section as shown below, we can also set whether bind variable is allowed to be passed in REST resource URL along with Required settings.

rf

Deploy the application and use any REST client to test GET method using the following urls. Observe the usage of row finder and bind variables.

Passing single bind variable:

http://localhost:7001/departmentApi/rest/r1/departments?finder=searchByDeptName;bindDeptName=A

Passing both bind variables:

http://localhost:7001/departmentApi/rest/r1/departments?finder=searchByDeptName;bindDeptName=A,bindLocId=1800

Now mark bindLocId variable as required and try to test without using it in the URL and you will observe the error as shown below.

error

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

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.