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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to