Oracle SOA Suite 11g Developer's Cookbook
Oracle SOA Suite 11g Developer's Cookbook
Author
Priyadharshini Jayaraman
jdev patch
jsontoXml
XMLToJson
$filter
get
post
build the URI dynamically and assign it to “rest.binding.requestURI” property of Invoke activity.
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 3: Set your current directory to the directory where the patch is located.
$ cd PATCH_TOP/30482761
$ 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}”
Bearer Token:
Getting Ready…
{
"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….
Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9ZbJg4nFmXbUxMnhMSTPw3TW5PE75TxZcqt64TJ_
1P0PkArfoLg7_34dZSwb-8Z2z_jsNdaVNndaIvB9DIbFr4-qSwTdMqFCFQeAYjknyXWSq28cXMzu-
7dJVplwqi91jawJdcozW1bZGzJM3nkPDhVzb7fqwWyrZxQt5YsXuni2yuujGPwHOSd8JNezRG-
NVEBzJ1HaYAD3io3wOcTEP6u4vXP4BhV4Dpkq61ctPhEqpSC7gGZZrtz_m7JcCyWC7Hn1KQ
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…
How to do it…
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….
{
"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…..