Friday, August 11, 2023

OIC - How to convert XML data to Json data and store it in a variable

Usecase: Here we have a requirement that Source will send xml payload using our exposed or triggered SOAP API and then we will convert it to JSON format and store it in a variable to insert the json data into a database table.

Logic steps:

  1. Create a WSDL file and create a SOAP trigger connection.
  2. Create a App driven orcehstration  and configure with the created soap connection
  3. Take a stage and write file with json sample and map the xml data to json data.
  4. Take stage again and read the json file using opaque schema
  5. Take a assign and create a variable and store the read file reference with decodebase64().
  6. Add tracking, save, activate , copy the wsdl and open a project in soap ui tool and add basic authentication and test


Opaque xsd:

https://soalicious.blogspot.com/2022/02/xsd-opaque-schema.html

Users.json:

{

"Users":{

"User":[

{

"id": 1,

"firstName":"string",

"lastName":"string",

"email":"string",

"country":"string"

},

{

"id": 2,

"firstName":"string",

"lastName":"string",

"email":"string",

"country":"string"

},

{

"id": 3,

"firstName":"string",

"lastName":"string",

"email":"string",

"country":"string"

}

]

}

}


Used oneway wsdl:

https://soalicious.blogspot.com/2023/08/wsdl-oneway-users-wsdl-file.html

Detailed with screenshots:

Soap connection:



Integration flow:


Configure soap trigger






Stage to write xml to json file







Read the json file as opaque:





Take assign and map the read file reference with decodebase64() inbuilt function.


Test from SOAPUI


Monitoring >> activity stream



No comments:

Post a Comment

Featured Post

OIC - how can I use XSLT functions to remove leading zeros from numeric and alphanumeric fields?

To remove leading zeros from an numeric field in Oracle Integration Cloud (OIC) using XSLT, you can Use number() Function The number() funct...