I'm trying to base64 encode a request XML by storing it first in a BPEL varible. Could you please have a look at the problem and suggest me what I did wrong and how the same can be fixed?
e.g. When I decode the encoded message, I get the output as
<varName ns0="namespace">
</varName>
instead of
<ns0:input ns0="namespace">
</ns0:input>
The base64 code is as below -
try{
oracle.xml.parser.v2.XMLElement inputPayload = (oracle.xml.parser.v2.XMLElement)getVariableData("varName");
oracle.xml.parser.v2.XMLDocument xmlPayload = inputPayload.getDocument();
java.io.ByteArrayOutputStream outputStream = new java.io.ByteArrayOutputStream();
xmlPayload.print(outputStream);
java.lang.String xml_output = outputStream.toString("UTF-8");
xml_output = xml_output.substring(12, xml_output.length()-14);
java.lang.String xml_oneLine = xml_output.replaceAll("\\s*[\\r\\n]+\\s*", "").trim();
xml_oneLine = xml_oneLine.replaceAll("(^\\h*)|(\\h*$)","").trim();
java.lang.String xml_encoded = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +xml_oneLine;
oracle.soa.common.util.Base64Encoder encoder = new oracle.soa.common.util.Base64Encoder();
java.lang.String encodedString = null;
encodedString = encoder.encode(xml_encoded.trim());
setVariableData("outputVariableName", "requestVariableName", "XPath", encodedString);
outputStream.close();
}
Kind Regards, Jaihind