How to embed CDATA into XML: Oracle Integration Cloud
There is a scenario where you are required to consume SOAP API and the API require to send CDATA as part of the request. In the article, we are going to showcase how to embed the CDATA into the XML request in Oracle Integration Cloud.
Some important link which might help you to extend your knowledge
Call External REST API: Oracle Integration Cloud
Create an Integration in ICS to expose SOAP API
Let’s first understand what CDATA is?
A Character Data(CDATA) section contains text that will NOT be parsed by a parser. Tags inside a CDATA section will NOT be treated as markup and entities will not be expanded. The primary purpose is for including material such as XML fragments, without needing to escape all the delimiters.
Example of SOAP API having the CDATA
In the below SOAP API request, please see the “<general:BPXML>” and under this CDATA element is there. When you will consume the same into OIC, you will not see the end elements( <wrapper>, <emp>, <name>, etc. ) under CDATA in mapper. If not found in the mapper how you will send the data to SOAP request which is required.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:general="http://general.service.webservices.com"> <soapenv:Header/> <soapenv:Body> <general:create> <!--Optional:--> <general:code>123</general:code> <general:BPXML> <![CDATA[ <Wrapper> <emp> <name>Ankur</name> <age>23</age> <qual>MCA</qual> <empid>1223</empid> <status>Active</status> </emp> </Wrapper> ]]> </general:BPXML> </general:create> </soapenv:Body> </soapenv:Envelope>
- Extract the XML under CDATA (<wrapper>…..</wrapper) and create a wrapper.xml file
<Wrapper> <emp> <name>Ankur</name> <age>23</age> <qual>MCA</qual> <empid>1223</empid> <status>Active</status> </emp> </Wrapper>
- Use the Stage activity to create the XML file and upload the sample wrapper.xml
- Use stage activity to read the file using “opaque.xsd”
<?xml version = '1.0' encoding = 'UTF-8'?> <schema targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/opaque/" xmlns="http://www.w3.org/2001/XMLSchema" > <element name="opaqueElement" type="base64Binary" /> </schema>
- Open the SOAP request mapper and map the “general:BPXML” with oraext:decodeBase64(opaqueElement)
Run the service and notice XML should be added under “general:BPXML” element.
Subscribe to my YouTube to get the latest videos.