4 Replies Latest reply: Dec 28, 2011 11:17 PM by 894980 RSS

    Binary to String Conversion issues in OSB for special characters

    894980
      Hello All,

      Below are the details of the issue. Any help is much appreciated.

      Description:
      We receive messages of the type base64Binary (binary message) into OSB. We are using Base64Coder Java function to convert the binary message into String.

      Issue is while converting the special characters (like ´ÕâÐÛØ íÚáÚÐÒÐâÞàÐ )from binary to string.

      The code works fine on Windows 64 bit OS, but it fails to convert the special characters (converted to ????) once we deploy the java function and OSB code onto the server installed on Solaris OS.

      Pls help if you have faced this issue earlier.

      Regards
      Aparna
        • 1. Re: Binary to String Conversion issues in OSB for special characters
          Anuj Dwivedi--Oracle
          You may use method decode() and encode() of class org.apache.xerces.impl.dv.util.Base64 which is present in jar com.bea.core.apache.xercesImpl_2.8.1.jar (in $MW_Home\modules) for base64 encoding and decoding-

          http://xerces.apache.org/xerces2-j/javadocs/xerces2/org/apache/xerces/impl/dv/util/Base64.html
          The code works fine on Windows 64 bit OS, but it fails to convert the special characters (converted to ????) once we deploy the java function and OSB code onto the server installed on Solaris OS.
          How did you find that special characters are getting converted to question marks (??)? Remember that if you are trying to open a file in Solaris which has characters not listed in platform encoding of Solaris then it will be displayed as question mark.

          Regards,
          Anuj
          • 2. Re: Binary to String Conversion issues in OSB for special characters
            894980
            Hi Anuj,

            Thanks so much for the prompt reply. Reg. your question, I am viewing the output from OSB test console. In my local OSB server test console am able to view the output of the special characters properly, but on the OSB server deployed on Solaris, test console is showing ???? characters after conversion.

            Is the OSB test console the correct way to check the conversion??

            Regards
            Aparna
            • 3. Re: Binary to String Conversion issues in OSB for special characters
              Anuj Dwivedi--Oracle
              Hello Aparna,

              It is necessary to make sure that the lang/localization settings of your OS are correct for the characters you are using. Ask your OS admin to change the locale settings to de_DE.UTF-8 and test again.

              Regards,
              Anuj
              • 4. Re: Binary to String Conversion issues in OSB for special characters
                894980
                Hi Anuj,

                The issue now got resolved. I got the Solaris OS Locales updated by the admin guy. Also I made changes to my Java function return statement - "return new String (Base64.decode(stringToConvert) , "UTF-8");". Earlier the return statement was just "return new String (Base64.decode(stringToConvert));". Thanks so much for your tips and suggestions.

                For anyone's reference, I have copied below the complete java program for encoding string to binary and decoding binary:

                import java.io.*;
                import org.apache.xerces.impl.dv.util.Base64;
                public class Util
                {
                public static String encodeBase64(String stringToConvert) throws UnsupportedEncodingException
                {
                try {  return Base64.encode (stringToConvert.getBytes("UTF-8"));  }
                catch (Exception e)
                {    return ("Error during Encoding");  }
                }
                public static String decodeBase64(String stringToConvert) throws UnsupportedEncodingException
                {
                try {  return new String (Base64.decode(stringToConvert) , "UTF-8");  }
                catch (Exception e)
                { return ("Error during Decoding");  }
                }
                }

                Regards
                Aparna