Monday, March 19, 2018

How to Decompress the XML from Base 64 format in BPEL | GZIP | SOA

Below is the Java embedding code to decompress the base 64 format into a XML.

try                                                     
{     
//Base 64 Format to Bytes 
oracle.xml.parser.v2.XMLElement inputPayload = (oracle.xml.parser.v2.XMLElement)getVariableData("Invoke_Target_OutputVariable","Result","/response/paylaod");           
String inputstr = inputPayload.getTextContent();
byte[] valueDecoded = org.apache.commons.codec.binary.Base64.decodeBase64(inputstr.getBytes());
//Bytes to GZIP
java.util.zip.GZIPInputStream zis = new java.util.zip.GZIPInputStream((java.io.InputStream) new java.io.ByteArrayInputStream(valueDecoded));
//GZIP to XML
StringBuilder xmlStr = new StringBuilder();
byte[] buffer = new byte[1024];
int read = 0;
while (zis.available()==1) {
while ((read = zis.read(buffer, 0, 1024)) >= 0) {
xmlStr.append(new String(buffer, 0, read));
}
}
String xmlMsg = xmlStr.toString();
//Assign XML to a Variable in BPEL
setVariableData("Temp_EBM", xmlMsg); 
}                                                 
catch(Exception e)                                                 
{                                                 
e.printStackTrace();                                                 
}

To learn how to compress, please use below link.
How to compress xml using gzip in bpel

No comments:

Post a Comment