Wednesday, April 6, 2022

OIC - Post XML payload with Rest API | Rest API with XML Request Response

Here, we will expose rest Trigger API and post XML request payload to Rest api and get back a response as XML by the rest API.

Request schema used:

<?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>

Response schema used:

<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.pocresponse.org" xmlns:ns0="http://www.pocresponse.org" targetNamespace="http://www.pocresponse.org"
            elementFormDefault="qualified">
  <xsd:element name="EmployeesRes">   
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="EmployeeRes" 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="DEPARTMENT_ID" type="xsd:string"/>
<xsd:element name="COUNTRY" type="xsd:string"/>
      </xsd:sequence>
    </xsd:complexType>
</xsd:schema>

Detailed steps:

Integration view:


Take a Rest trigger and configure



Choose request payload as XML_Schema and media type of the request body as XML.


Choose response payload as XML_Schema and media type of the response body as XML.


Map the request to response


Test 



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...