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="http://org.poc.com/v1.0">
<XMLString>abcd</XMLString>
</Input>
Response schema for Rest API:
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.poc.org" xmlns:ns0="http://www.poc.org" targetNamespace="http://www.poc.org"
elementFormDefault="qualified">
<xsd:element name="Employees">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Employee" type="EmployeeType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="EmployeeType">
<xsd:sequence>
<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"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
XML data:
<?xml version="1.0" encoding="utf-8"?>
<Employees>
<Employee>
<EMPLOYEE_ID>str1234</EMPLOYEE_ID>
<FIRST_NAME>str1234</FIRST_NAME>
<LAST_NAME>str1234</LAST_NAME>
<AGE>str1234</AGE>
<DEPARTMENT_NAME>str1234</DEPARTMENT_NAME>
<DEPARTMENT_ID>str1234</DEPARTMENT_ID>
<COUNTRY>str1234</COUNTRY>
<SALARY>str1234</SALARY>
</Employee>
</Employees>
String XML data to be tested:
<?xml version="1.0" encoding="utf-8"?>
<Employees>
<Employee>
<EMPLOYEE_ID>str1234</EMPLOYEE_ID>
<FIRST_NAME>str1234</FIRST_NAME>
<LAST_NAME>str1234</LAST_NAME>
<AGE>str1234</AGE>
<DEPARTMENT_NAME>str1234</DEPARTMENT_NAME>
<DEPARTMENT_ID>str1234</DEPARTMENT_ID>
<COUNTRY>str1234</COUNTRY>
<SALARY>str1234</SALARY>
</Employee>
</Employees>
Detailed steps:
Integration flow:
No comments:
Post a Comment