You are on page 1of 11

Oracle SOA Suite 11g Developer's Cookbook

Author

Priyadharshini Jayaraman
jdev patch

passing query paramter

passing basic auth, bearer auth, apikey

jsontoXml

XMLToJson

$filter

config plan change to pass dynamic baseURI

get

post

url-encoded {} perficient example

build the URI dynamically and assign it to “rest.binding.requestURI” property of Invoke activity.

post clientsecret, auth params as url-encoded in body

1. Jdeveloper Patch for enabling JSON Nxsd:

Generating NXSD out of Json is necessary to perform the REST API Operations. Jdeveloper 12.2.1.4
has a bug, where, generating NXSD for JSON throws an error. The below describes the necessary
steps to fix the issue

Getting Ready

Please perform the below steps and see if you get the JSON Factory Error.
In that case, perform the Patch Installation in Jdeveloper.

ERROR
-----------------------
Error creating stream factory: java.lanf.NoClasDefFoundError:
com/fasterxml/jackson/core/JsonFactory
Step 1: In a sample BPEL Process, right-click and create new NXSD Schema.

Step 2: Navigate to next and select JSON Interchange Format and give the below json
sample as below

{
"body" : "Test_Body",
"id": "1",
"title":"test",
"userId":"1"
}
Step 3: Give Next and if you see the below Json Factory class def error, follow the steps
provided in the attached document to install the jdeveloper patch to resolve this issue.

Note: In the next step, incase you got the nxsd created out of the sample json data
successfully, You are good to go. No need to perofrm the patch installation. 
How to do it……….

Use the Patch.30482761 zip file which is attached over the email

Step 1: Create folder as “PATCH_TOP” in your C Drive. Avoid using locations like "C:\
Documents and Settings\username\PATCH_TOP". This is necessary due to the 256
characters limitation on windows platform.

Step 2: Unzip the attached patch file to PATCH_TOP folder

Step 3: Set your current directory to the directory where the patch is located.

Open the cmd.exe as Administrator

Step 4: Execute the below commands in cmd prompt

$ cd PATCH_TOP/30482761

$ set ORACLE_HOME= %Mention your Oracle Home%

$ set PATH= %ORACLE_HOME%\bin;%PATH%

$ set JAVA_HOME= %Mention your java 8 path%

$ set PATH=%JAVA_HOME%\bin;%PATH%
$ set PATH=%ORACLE_HOME%\Opatch;%PATH%

$ opatch apply

Once your patch is completed, you will see the OPatch succeeded

Step 5: Once Opatch is successfully installed, open your jdev in clean mode as mentioned
below

In cmd prompt, navigate to jdeveloper\jdev\bin folder and execute the below command

$ jdev -clean

There’s More……
Make sure Jdeveloper is closed before you start applying the opatch

2. RESTful Authorization

The below describes how to invoke the RESTful webservice by passing the various authentication
parameters as part of Header/Body. Across our interfaces, widely we are using Basic auth, Bearer
Token, Api Key.

Basic Auth

Getting Ready…..

For Basic Auth, collect the username and password from the api provider

Lets assume

Username = “basicusername”

Password=” basicpassword”

First the username and password needs to be encoded. So use the below syntax to encode using
online base64encoder tool for our example.

Syntax: basicusername:basicpassword

EncodedValue: YmFzaWN1c2VybmFtZTpiYXNpY3Bhc3N3b3Jk

How to do it…..

1. Create a simple string type variable “BasicAuth” to store Authorization Code in BPEL
2. EncodedValue needs to be passed as Authorization Header variable whose value is madeup
of a prefix “Basic” and the encoded value, separated by a single space.
3. Use concat function to build the BasicAuth value as below

“Basic {EncodedValue}”

4. Next step is to pass this BasicAuth as part of Header in the invocation


5. Double-click the “Invoke” activity and goto Properties Tab.
6. Click on Add Button and scroll down to rest adapter properties
7. Click on any rest adapter property and map your variable/expression with it.
8. Click ok.
9. Now, go to source view of the BPEL.xml and search for newly added rest adapter property
10. Replace Accept with “Authorization” as mentioned below

Bearer Token:

Getting Ready…

access_token will be generated by passing the client-credentials to the REST API.

Sample token response:

{
    "token_type": "Bearer",
    "subject_type": "employee",
    "subject": "12345",
    "subject_name": "Tester",
    "alternate_subject": "888",
    "alternate_subject_name": "888Test",
    "token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9ZbJg4nFmXbUxMnhMSTPw3TW5PE75TxZcqt64TJ_1P
0PkArfoLg7_34dZSwb-8Z2z_jsNdaVNndaIvB9DIbFr4-qSwTdMqFCFQeAYjknyXWSq28cXMzu-
7dJVplwqi91jawJdcozW1bZGzJM3nkPDhVzb7fqwWyrZxQt5YsXuni2yuujGPwHOSd8JNezRG-
NVEBzJ1HaYAD3io3wOcTEP6u4vXP4BhV4Dpkq61ctPhEqpSC7gGZZrtz_m7JcCyWC7Hn1KQ",
    "token_expires": "2020-09-04T04:11:36.8818657-07:00"
}
 
Extract the “token” value from the response

How to do it….

1. Token needs to be passed as Authorization Header variable whose value is madeup of a


prefix “Bearer” and the token value, separated by a single space.
2. Use concat function to build the BearerToken value as below

Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9ZbJg4nFmXbUxMnhMSTPw3TW5PE75TxZcqt64TJ_
1P0PkArfoLg7_34dZSwb-8Z2z_jsNdaVNndaIvB9DIbFr4-qSwTdMqFCFQeAYjknyXWSq28cXMzu-
7dJVplwqi91jawJdcozW1bZGzJM3nkPDhVzb7fqwWyrZxQt5YsXuni2yuujGPwHOSd8JNezRG-
NVEBzJ1HaYAD3io3wOcTEP6u4vXP4BhV4Dpkq61ctPhEqpSC7gGZZrtz_m7JcCyWC7Hn1KQ

1. Next step is to pass this token as part of Header in the invocation


2. Double-click the “Invoke” activity and goto Properties Tab.
3. Click on Add Button and scroll down to rest adapter properties
4. Click on any rest adapter property and map your variable/expression with it.
5. Click ok.

1. Now, go to source view of the BPEL.xml and search for newly added rest adapter property
2. Replace Accept with “Authorization” as mentioned below
API-Key:

Getting Ready…

Api-key value will be provided by the client application

How to do it…

1. Store the api key in a variable

6. Next step is to pass this token as part of Header in the invocation


7. Double-click the “Invoke” activity and goto Properties Tab.
8. Click on Add Button and scroll down to rest adapter properties
9. Click on any rest adapter property and map your variable/expression with it.
10. Click ok.

1. Now, go to source view of the BPEL.xml and search for newly added rest adapter property
2. Replace Accept with “x-api-key” as mentioned below
1. Json To XML Conversion

Getting Ready….

Assume below is the sample json, which we will convert to XML

{
     "firstName": "John",
     "lastName": "Smith",
     "age": 25,
     "address":
     {
         "streetAddress": "21 2nd Street",
         "city": "New York",
         "state": "NY",
         "postalCode": "10021"
     },
     "phoneNumber":
     [
         {
           "type": "home",
           "number": "212 555-1234"
         },
         {
           "type": "fax",
           "number": "646 555-4567"
         }
     ]
 }

How to do it…..

1. Translate activity is used to convert Json to XML and Vice versa


2.

You might also like