We are being able to do the following.
In VBA 6/ VBA 7:
- Refer a 32 bit zlibwapi.dll (VBA 6) or 64 bit zlibwapi.dll (VBA 7).
- Invoke compress() or compress2() methods to generate compressed
streams - Invoke uncompress() and uncompress2() methods to decompress compressed streams
In Java 8 (JDK 1.8 on Tomcat 8)
- Have a simple java program that compresses data using the new Deflater() instance
- Have a simple Java program that decompresses using Inflater() instance
We are failing when VBA sends out the compressed stream for Java Servlet to uncompress or when Java Servlet sends out compressed response data for VBA to decompress.
We are aware of following facts.
- there are 3 formats provided by ZLib (raw, zlib and gzip).
- The methods in zlibwapi.dll namely compress() and compress2() generates compressed bytes in zlib format. This has been mentioned in a similar thread at Java decompressing array of bytes
- Inflater() instance on Java side allows to uncompress zlib format data as per a code sample posted at Compression / Decompression of Strings using the deflater
- Java 8 has zlib version 1.2.5 integrated as part of java.utils.zip package.
- We have ensured that we are using zlibwapi.dll version 1.2.5 on VBA side as well.
We have tried to use Hex editors to compare byte streams of compressed data independently generated by VBA and Java as well. We notice some difference in the generated compressed data. We think it is this difference that is causing both the environments to misunderstand each other.
Additionally, we think that when communication occurs, there has to be some common charset that governs the encoding/decoding scheme between both the endpoints. We have even tried to compare the hex code of byte stream generated by VBA and communicated across to Java Servlet.
- The bytes seem to be getting some additional 0 bytes inserted in between the actual set of compressed bytes while communication occurs. This happens on VBA side. May be because of some unicode interpretation.
- Whatever bytes get communicated across to Java appear entirely different in their representation.
We need to fix our independently working code to communicate with one another and compress and decompress peacefully. We think there are 2 things to address - Getting format to match and using a charset that sends bytes as is. We are looking for any assistance from experts on this front that can help us find correct path to the possible solution. We need answers for
- Does compress2() or compress() really generate zlib format?
- Which charset will allow us to send bytes as is (if there are 10 bytes, we want to send 10 bytes. Not 20). If its unicode, 0 bytes get inserted in between (10 bytes become 20 bytes because of this).