xmlcorba

Attaching a gzip string to xml content


I am sending xml response to other system via corba. I have a file which is needed to send as response. The file size is big and I want it to compress it and attach to xml.

Is it possible to attach compressed string to xml content in CDATA section

I tried with base64 but it’s not compressing the string much.


Solution

  • Base64 doesn't do compression. On the contrary, if you convert an octet stream to base64 the result uses 8 bits for every 6 bits in the input. The reason to use Base64 is that it allows you to represent an arbitrary octet stream using ASCII characters only.

    You need to compress the file first, and then apply base64 encoding to represent the compressed octet stream in XML.

    CDATA is irrelevant: Base64 data doesn't use any characters that need escaping in XML. You don't need to put the Base64 inside a CDATA section.