Wednesday, January 8, 2025

OIC - Can we send XML input in rest adapter?

Yes, the REST adapter in OIC can handle XML input.

  1. Set the media type to application/xml.
  2. Define an XML schema (XSD) for payload mapping.
  3. Include Content-Type: application/xml in the request header.
  4. Test with XML payloads using Postman or curl.

Ensure proper configuration and schema matching for seamless processing.

๐Ÿ“˜ Sending XML Payload Using REST Adapter in Oracle Integration Cloud (OIC)

๐Ÿ” Use Case

In many integration scenarios, especially when integrating with legacy or enterprise systems, XML continues to be the standard format for data exchange. In this blog, we will demonstrate how to:

  • Receive an XML request in a REST service.
  • Parse the XML structure based on an XSD.
  • Respond with structured XML data using a REST Adapter in OIC.

We will use an Employee Lookup Service as our example:

  • The client sends an EmployeeRequest with empId.
  • The integration returns an EmployeeResponse with full employee details (firstName, lastName, email, department).

๐Ÿ“„ XSD Schema (Employee.xsd)

This XSD defines the request and response structures:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://example.com/employee"
    xmlns="http://example.com/employee"
    elementFormDefault="qualified">

    <!-- Request element -->
    <xsd:element name="EmployeeRequest">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="empId" type="xsd:string" minOccurs="1"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>

    <!-- Response element -->
    <xsd:element name="EmployeeResponse">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="empId" type="xsd:string"/>
                <xsd:element name="firstName" type="xsd:string"/>
                <xsd:element name="lastName" type="xsd:string"/>
                <xsd:element name="email" type="xsd:string"/>
                <xsd:element name="department" type="xsd:string"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>

</xsd:schema>

๐Ÿ”ง Step-by-Step Solution in OIC

1. Create Integration

  • Type: App Driven Orchestration
  • Trigger: REST Adapter (Configure for XML payload)

2. Configure REST Adapter

  • Choose "XML" as Payload format.
  • Upload the above Employee.xsd file.
  • Select EmployeeRequest for Request and EmployeeResponse for Response.

3. Map Data in Orchestration

  • Use a switch or if condition to check empId.
  • Create response payload dynamically based on ID.
  • Use the Mapper to build the EmployeeResponse.

4. Activate and Test Integration

  • Deploy and test via Postman or SOAP UI using XML body.

๐Ÿงพ Sample Request

<EmployeeRequest xmlns="http://example.com/employee">
    <empId>EMP1001</empId>
</EmployeeRequest>

✅ Sample Response

<EmployeeResponse xmlns="http://example.com/employee">
    <empId>EMP1001</empId>
    <firstName>John</firstName>
    <lastName>Doe</lastName>
    <email>john.doe@example.com</email>
    <department>Finance</department>
</EmployeeResponse>

๐Ÿ›  Tips

  • Always validate the uploaded XSD to ensure no namespace issues.
  • Use Test -> Mapper feature to validate XML mapping.
  • Enable tracking on the empId element for easier monitoring.

๐Ÿ“š Conclusion

This blog shows how to handle XML payloads using REST Adapter in Oracle Integration Cloud. You can apply this approach for any service that relies on XSD-based XML payloads. Using XML ensures schema validation and strong structure enforcement, especially when integrating with older systems.


With screenshots:

Configuring at Trigger :




Configuring at invoke:






Testing:



No comments:

Post a Comment

Featured Post

OIC - Sending JSON Data as Email Body Content via Twilio SendGrid API in OIC

Use Case Description: When integrating Oracle Integration Cloud (OIC) with Twilio SendGrid API to send emails, JSON data intended for the em...