axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carlos Perez" <cpe...@ihmc.us>
Subject Possible Axiom Bug: base64 encoding
Date Sat, 17 Jun 2006 02:33:40 GMT
Hi,

I have been trying to consume an Axis2 web service that 
returns binary data in base64 from a .NET client, and the 
client is complaining about invalid characters in the 
base64 string. I took a look at the string and actually 
the base64 string is including '=' chars in the middle of 
the string, but this char is only allowed at the end of 
the string, for padding. So I took a look at the code for 
the class org.apache.axiom.om.impl.llom.OMTextImpl and 
there seems to be a bug in the base64 encoding process, in 
the method getText(). This method is encoding chunks of 
1024 bytes at a time; base64 encodes 3 bytes at a time, 
and as 1024 is not a multiple of 3 then a pad of two '=' 
chars is generated for every chunk. I think that with a 
chunk size that is multiple of 3  (i.e. 1023), this 
problem could be solved.


    public String getText() throws OMException {
        ...
                 InputStream inStream;
                 inStream = this.getInputStream();
                 byte[] data;
                 StringBuffer text = new StringBuffer();
                 do {
                     data = new byte[1024];
                     int len;
                     while ((len = inStream.read(data)) > 
0) {
                         byte[] temp = new byte[len];
                         System.arraycopy(data, 0, temp, 
0, len);
                         text.append(Base64.encode(temp));
                     }

                 } while (inStream.available() > 0);

       ...
     }




---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Mime
View raw message