Thursday, April 7, 2022

OIC - Convert String XML to XML using parseXML() | Use of ParseXML() function

Usecase: we will receive string xml data from source and then convert it back to XML content using parseXML() function and Rest API.

Highlevel steps: 

  • Using rest connection, configure app driven orchestration integration request and response.
    • In request & response, we will use XML schema as  payload format.
  • In the map, we will take parseXML() function which takes string XML as argument and map to execute response.
  • In the map code, change the value-of element name to copy-of. If you use only value-of then we will get only the parsed xml values ,not the element names. TO get values with element names, we have to use copy-of element.

Request XML for Rest API:
<?xml version="1.0" encoding="utf-8"?>
<Input xmlns="">

Response schema for Rest API:
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="" xmlns="" xmlns:ns0="" targetNamespace=""
  <xsd:element name="Employees">   
        <xsd:element name="Employee" type="EmployeeType" minOccurs="0" maxOccurs="unbounded"/>
    <xsd:complexType name="EmployeeType">
        <xsd:element name="EMPLOYEE_ID" type="xsd:string"/>
        <xsd:element name="FIRST_NAME" type="xsd:string"/>
<xsd:element name="LAST_NAME" type="xsd:string"/>
<xsd:element name="AGE" type="xsd:string"/>
<xsd:element name="DEPARTMENT_NAME" type="xsd:string"/>
<xsd:element name="DEPARTMENT_ID" type="xsd:string"/>
<xsd:element name="COUNTRY" type="xsd:string"/>
<xsd:element name="SALARY" type="xsd:string"/>

XML data:
<?xml version="1.0" encoding="utf-8"?>

String XML data to be tested:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;

Detailed steps:

Integration flow:

Take rest trigger and configure post with request and response.

Map the requeest to response using parseXML().

In the map code, change value-of with copy-of elelment name.

Add tracking, save, activate and test.

No comments:

Post a Comment

Featured Post

11g to 12c OSB projects migration points

1. Export 11g OSB code and import in 12c Jdeveloper. Steps to import OSB project in Jdeveloper:   File⇾Import⇾Service Bus Resources⇾ Se...