我编写了一个 UDF 来解码 SAP PI 映射中的 endcode base64 文本。但是在解码 xml 标签后,打开和关闭标签都被替换为> <
请在下面找到代码的屏幕截图。
public String Base64Decoder(String EncodedString, Container container) throws StreamTransformationException
{
//Variable to hold decoded string
String decodedString = null;
byte[] decodedBytes = DatatypeConverter.parseBase64Binary(EncodedString);
try{
//Convert base64 schema to byte array
return new String(decodedBytes,"UTF-8");
//Get the string of decoded byte array
}catch(Exception e) {
}
//Export decoded string
return decodedString;
}
解码后输出:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Log xmlns:ns0="http://world.com/pi/M/Log">
<Data><OUTPUT><item><VBELN>0180001027</VBELN><WADAT>00000000</WADAT><VSTEL>1000</VSTEL><KUNNR/><ITEM><YITEM><MATNR>000000000011000082</MATNR><LFIMG>1.0</LFIMG><MEINS>L</MEINS></YITEM></ITEM></item><item><VBELN>0180001233</VBELN><WADAT>00000000</WADAT><VSTEL>1000</VSTEL><KUNNR/><ITEM><YITEM><MATNR>000000000041000000</MATNR><LFIMG>10.0</LFIMG><MEINS>LM</MEINS></YITEM></ITEM></item></OUTPUT></Data>
</ns0:Log>
标签内的数据<Data>
是解码的文本。但正如你所看到的,它的所有标签都被替换了。例如,而不是<OUTPUT>
打印<OUTPUT>
您能否让我知道我应该在 UDF 中进行哪些更改以避免这种情况。
Base64 编码字符串:
PE9VVFBVVD48aXRlbT48VkJFTE4+MDE4MDAwMTAyNzwvVkJFTE4+PFdBREFUPjAwMDAwMDAwPC9XQURBVD48VlNURUw+MTAwMDwvVlNURUw+PEtVTk5SLz48SVRFTT48WUlURU0+PE1BVE5SPjAwMDAwMDAwMDAxMTAwMDA4MjwvTUFUTlI+PExGSU1HPjEuMDwvTEZJTUc+PE1FSU5TPkw8L01FSU5TPjwvWUlURU0+PC9JVEVNPjwvaXRlbT48aXRlbT48VkJFTE4+MDE4MDAwMTIzMzwvVkJFTE4+PFdBREFUPjAwMDAwMDAwPC9XQURBVD48VlNURUw+MTAwMDwvVlNURUw+PEtVTk5SLz48SVRFTT48WUlURU0+PE1BVE5SPjAwMDAwMDAwMDA0MTAwMDAwMDwvTUFUTlI+PExGSU1HPjEwLjA8L0xGSU1HPjxNRUlOUz5MTTwvTUVJTlM+PC9ZSVRFTT48L0lURU0+PC9pdGVtPjwvT1VUUFVUPg==