How to accept and respond with SOAP XML payloads in a REST API
Use Case
Many legacy systems still use SOAP-based XML messages for data exchange, while modern applications and integrations often rely on REST APIs.
In this scenario, we need to create an OIC REST Trigger that can:
- Accept a SOAP XML payload as input (request).
- Process the data.
- Return a SOAP XML response back to the caller.
This allows seamless communication between SOAP-based systems and modern RESTful endpoints without requiring the legacy system to change.
Solution Steps
1. Design the OIC Integration
- Create a new App-Driven Orchestration in Oracle Integration.
- Select REST as the trigger connection.
2. Configure the REST Trigger
- Resource URL: e.g.,
/soapxmlhandler
- HTTP Method:
POST
- Request Payload:
- Set the media type to
application/xml
ortext/xml
. - Paste the SOAP request XSD in the request schema section.
- Set the media type to
- Response Payload:
- Also use
application/xml
ortext/xml
. - Paste the SOAP response XSD in the response schema section.
3. Import the SOAP Envelope Schema
- Use the
SOAPENV.xsd
(like the 2006 OGC version in your screenshot) to define the outer SOAP structure. - Import your business-specific XSD (e.g.,
VoltageDipIncidentCustomerAccountsMessage.xsd
) for the actual payload.
Add import to include xsd required.
<xs:import namespace="http://iec.ch/TC57/2011/VoltageDipIncidentCustomerAccountsMessage"
schemaLocation="VoltageDipIncidentCustomerAccountsMessage.xsd"/>
<xs:element name="Body" type="tns:Body"/>
<xs:complexType name="Body">
<xs:sequence>
<xs:element ref="ns1:VoltageDipIncidentCustomerAccountsResponseMessage"/>
<xs:element ref="ns1:CreatedVoltageDipIncidentCustomerAccounts"/>
</xs:sequence>
<xs:anyAttribute namespace="##any" processContents="lax">
<xs:annotation>
<xs:documentation>
Prose in the spec does not specify that attributes are allowed on the Body element.
</xs:documentation>
</xs:annotation>
</xs:anyAttribute>
</xs:complexType>
Reference SOAPENV used:
4. Map the Incoming SOAP Request
- Use OIC’s mapper to extract the SOAP Body content into integration variables.
- Process or transform as required.
5. Prepare the SOAP Response
- Map your processed data back into the SOAP Response structure.
- Ensure proper namespace handling (as per the SOAP schema).
6. Test the REST Endpoint
- Use Postman or SOAP UI:
- Send a
POST
request with the full SOAP XML as the body. - Set the
Content-Type
header totext/xml
.
- Send a
- Verify that the response is a valid SOAP envelope.
Tested xml data:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns1="http://iec.ch/TC57/2011/VoltageDipIncidentCustomerAccountsMessage">
<s:Body>
<ns1:CreatedVoltageDipIncidentCustomerAccounts>
<!-- Header Section -->
<Header>
<Verb xmlns="http://iec.ch/TC57/2011/schema/message">created</Verb>
<Noun xmlns="http://iec.ch/TC57/2011/schema/message">VoltageDipIncidentCustomerAccounts</Noun>
<Revision xmlns="http://iec.ch/TC57/2011/schema/message">2.0</Revision>
<Timestamp xmlns="http://iec.ch/TC57/2011/schema/message">2024-08-05T09:59:30.3759213+08:00</Timestamp>
<Source xmlns="http://iec.ch/TC57/2011/schema/message">ABC</Source>
<MessageID xmlns="http://iec.ch/TC57/2011/schema/message">638584487073759213</MessageID>
<CorrelationID xmlns="http://iec.ch/TC57/2011/schema/message">638584487073759213</CorrelationID>
</Header>
<!-- Payload Section -->
<Payload>
<VoltageDipIncidentCustomerAccounts xmlns="http://iec.ch/TC57/2007/VoltageDipIncidentCustomerAccounts#">
<!-- Incident Record 1 -->
<IncidentRecord>
<mRID>INC1233038290</mRID>
<createdDateTime>2024-08-05T09:52:21+08:00</createdDateTime>
<CustomerAccounts>
<mRID>32812156411</mRID>
</CustomerAccounts>
<CustomerAccounts>
<mRID>32812156412</mRID>
</CustomerAccounts>
</IncidentRecord>
<!-- Incident Record 2 -->
<IncidentRecord>
<mRID>INC1233038291</mRID>
<createdDateTime>2024-08-05T08:32:25+08:00</createdDateTime>
</IncidentRecord>
<!-- Incident Record 3 -->
<IncidentRecord>
<mRID>INC1233038292</mRID>
<createdDateTime>2024-08-05T07:35:21+08:00</createdDateTime>
<CustomerAccounts>
<mRID>32812156412</mRID>
</CustomerAccounts>
</IncidentRecord>
</VoltageDipIncidentCustomerAccounts>
</Payload>
</ns1:CreatedVoltageDipIncidentCustomerAccounts>
</s:Body>
</s:Envelope>
7. Deployment
- Activate the integration in OIC.
- Share the REST endpoint URL with the consuming SOAP system.
No comments:
Post a Comment