In the previous article, I have showcased how to read XML files using FTP adapter. This article will show how to create XML files using FTP adapter.

Important Blogs to learn more about Oracle OIC
Use Case: Expose a REST API which will write XML file on FTP.

Post this blog, below XML file will be created on FTP location

<?xml version=”1.0″ encoding=”UTF-8″ ?>
<employees>
   <employee>
      <name>ankur</name>
      <skills>ICS</skills>
   </employee>
   <employee>
      <name>jain</name>
      <skills>java</skills>
   </employee>
</employees>

Let’s see how to achieve this use case

  • Create a FTP connection: Please go through the article to see how to create FTP connection
  • Create a REST connection. Please go through the article to see how to create REST connection
  • Go the the Integrations and click on the Create button from the upper right coner and select “App Driven Orchestration
  • Enter the Integration name as “WriteXMLFile” and click on the Create button.
  • Select inline drag REST connection on the Integration canvas as a Trigger point
  • Enter below information and click on the Next button
    • Name of the end point: WriteXML
  • Enter below information and click on the Next button
    • What is the endpoint’s relative resource URI: /create
    • What action do you want to perform on the endpoint: POST
    • Select Configure a request payload for this endpoint checkbox- This option allows us to assign payload in the next step

Write XML file in OIC

  • Select JSON Sample from the Select the request payload format drop down and then Select <<<inline>>> link to configure sample payload and enter below payload
{
“employee”:[
{
“name”:”ankur”,
“skills”:”ICS”
},
{
“name”:”Anil”,
“skills”:”Java”
}
]
}
REST Adapter in OIC
  • Click Done button from the Next Screen to complete the wizard
  • Drop FTP connection just below the REST adapter

FTP adapter in OIC

  • Enter the endpoint name as “WriteXMLFile” and click on the Next button
  • Enter below information and click on the Next button
    • Select Operation: Write File
    • Select a Transfer mode: ASCII
    • Output Directory: Enter the directory as /home/opc/target
    • File Name Pattern: Enter employee.xml

Write XML in OIC

  • Select “Yes” from Do you want to specify the structure for the content o the file? and select “XML schema (XSD) document from the drop down.

Write XML file in OIC

  • Save below xsd in file and browse
<xs:schema attributeFormDefault=”unqualified” elementFormDefault=”qualified” xmlns:xs=”http://www.w3.org/2001/XMLSchema”>
  <xs:element name=”employees”>
    <xs:complexType>
      <xs:sequence>
        <xs:element name=”employee” maxOccurs=”unbounded” minOccurs=”0″>
          <xs:complexType>
            <xs:sequence>
              <xs:element type=”xs:string” name=”name”/>
              <xs:element type=”xs:string” name=”skills”/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Write XML file in OIC

  • Click Done on Next screen to finish the wizard
  • Edit the WriteXMLFile mapper and map source and target element

Write XML file in OIC

  • Required configuration has been completed. Let’s save, close and activiate the integratoin now.
  • Test the Integration using the inbuit tool by clicking on the Run icon and click on Test

TEST OIC integration

  • Open the FTP location and see the employee.xml should be created
Look at my YouTube channel for OIC related video and Subscribe to YouTube channel to get the latest updates.