Jump to content
  • BW6.X - BWCE - How to decode / encode a string in binary format in BusinessWorks and BusinessWorks Container Edition


    Some integration scénarios requires to decode strings received in binary format or in the other way to encode strings in binary format.

    This article goal is to explain how to do this in BusinessWorks and BusinessWorks Container Edition.

    Decoding a string

    In such scénario BusinessWorks receives a byte string that contains an encoded character string, for example in UTF-8, and there is need to handle the character string as a String in BusinessWorks.

    In BusinessWorks a byte string is handled as a field of type Binary and internally managed as a base64 string.

    So what we need to do is simply to decode the base64 string with the encoding used by the sender application when creating the received byte string.

    This can be done using the following XPATH formula (if the source encoding is UTF-8):

    tib:base64-to-string(xsd:string($FilePoller/fileContent/binaryContent), “UTF8”)

    Note that internally BusinessWorks is using Unicode (UTF-16 encoding) to manage Strings.

    1*lT_l_fV3iFD5dofASUEKJA.png

    Encoding a string

    In such scénario BusinessWorks transforms a String in a byte string using a given encoding.

    In this case what we need to do is simply to encode the String in a base64 string with the needed encoding.

    This can be done using the following XPATH formula (in this example the target encoding is IBM297):

    xsd:base64Binary(tib:string-to-base64($Mapper/primitive, “IBM297”))

    1*snuffT13Yc_KpV0WE1gGwA.png

    Useful elements

    The available encodings are the one supported by Java, the list is available here:

    https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html

    You can find more details on encoding in the following blog article from my colleague René Kiessling:

    https://medium.com/@rdkiessling/can-one-use-a-low-code-application-platform-for-data-exchange-with-legacy-systems-7f93aae716a3

    Additional elements

    You can refer to the attached project.

    EncodeDecodeDemo.zip


    User Feedback

    Recommended Comments

    There are no comments to display.



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...