Yes, the REST adapter in OIC can handle XML input.
- Set the media type to application/xml.
- Define an XML schema (XSD) for payload mapping.
- Include Content-Type: application/xml in the request header.
- 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
withempId
. - 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 theempId
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 :
No comments:
Post a Comment