Base64 Expressions

Overview

Provides simple Base64 functions intended for use on SAIL interfaces:

Key Features & Functionality

  • decodeSimpleBase64(text) - decode a base64 string. Max length 150 characters.
  • encodeSimpleBase64(text) - encode a base64 string. Max length 150 characters.
  • decodeHexString(text) - decode a hex string
  • hex2base64(text) - converts hex encoded string to base64encoded string
Anonymous
Parents
  • We are trying to integrate with a client's external system to send notifications. One of the input parameters of this system is "singleMessage" which is of type text and must be passed an XML converted to base64 with the email parameters (body, recipients, attachments, etc.). To convert the XML to Base64 I use the encodebase64string function (attached screenshot of the code), but this function corrupts the file. I also attach the request sent to the system and the resulting email (with the corrupt document).

    Could you help me?

  • Hi,

    This function is limited to 150 characters. You must update and recompile the plugin if you want to extend this limitation.

  • You are right, it is not a problem of limitation. It seem the limitation is now more than 150 chars.

    When I decode your base64, I can see "[Document:9399]" in your message. It is probably not you want.

    You try to put the document content by just setting fv!item. It cannot work.

    You must read the file content.and put the result inside. You can use the function readtextfromfile that is provided by the plugin Text File Utilities.

    The XML itself seem well formatted. I don't see any XML syntax error.

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?><solicitudUnicoType xmlns:xsi="">www.w3.org/.../XMLSchema-instance" xmlns:sms="SMSBus" xmlns:email="email" xmlns:push="push">
    <solicitud>
    <envioObligado>EMAIL</envioObligado>
    <email>
    <email:solicitudEmail>
    <email:codigoPeticion>PRUEBAPRE123</email:codigoPeticion>
    <email:destinatarios emailUnico="S">
    <email:destinatario>lfprados@minsait.com</email:destinatario>
    </email:destinatarios>
    <email:plantilla codigo="TESORERIA-NOTIFICACION"/>
    <email:asunto>Prueba notificación cambio de estado</email:asunto>
    <email:cuerpo>Estimado usuario,&lt;br&gt;&lt;br&gt;Se le informa de que la solicitud &lt;b&gt;00000001&lt;/b&gt; se encuentra en estado &lt;i&gt;'Autorizado, pendiente de validaci&amp;oacute;n'&lt;/i&gt;. Acceda al Portal en el siguiente enlace: &lt;br&gt;&lt;br&gt;csect-dev.appiancloud.com/.../design&lt;br&gt;&lt;br&gt;Un saludo.</email:cuerpo>
    <email:adjuntos>
    <email:adjunto id="idEjemplo" nombre="Prueba - copia - copia.pdf" extension="pdf">[Document:9399]</email:adjunto>
    </email:adjuntos>
    </email:solicitudEmail>
    </email>
    </solicitud>
    </solicitudUnicoType>

  • I know what I have really into the message.

    The request code is:

    {
    sourceApp: cons!ARQ_GNM_VALOR_SOURCE_APP,
    destinationApp: cons!ARQ_GNM_VALOR_DESTINATION_APP,
    singleMessage:
    encodebase64string(
    concat(
    "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>",
    "<solicitudUnicoType xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:sms=""SMSBus"" xmlns:email=""email"" xmlns:push=""push"">",
    "<solicitud><envioObligado>",
    /*(Opcional) Indicar si se debe realizar la comunicación solamente por una vía de envío: SMS, EMAIL, PUSH sin contingencias*/
    "EMAIL",
    "</envioObligado>",
    "<email><email:solicitudEmail><email:codigoPeticion>",
    ri!codigoPeticion,
    "</email:codigoPeticion><email:destinatarios emailUnico=""",
    cons!ARQ_GNM_VALOR_EMAIL_UNICO,
    """>",
    /*Destinatarios*/
    joinarray(
    a!forEach(
    items: ri!arrayDestinatarios,
    expression: char(10) & "<email:destinatario>" & fv!item & "</email:destinatario>"
    ),
    ""
    ),
    "</email:destinatarios><email:plantilla codigo=""",
    cons!ARQ_GNM_VALOR_CODIGO_PLANTILLA,
    """></email:plantilla><email:asunto>",
    ri!asunto,
    "</email:asunto><email:cuerpo>",
    toHtml(ri!cuerpo),
    "</email:cuerpo>",
    if(
    a!isNullOrEmpty(ri!adjuntos),
    null,
    concat(
    "<email:adjuntos>",
    a!forEach(
    items: ri!adjuntos,
    expression: concat(
    "<email:adjunto id=""idEjemplo"" nombre=""",
    document(fv!item, "name") & "." & document(fv!item, "extension"),
    """ extension=""pdf"">",
    fv!item,
    "</email:adjunto>"
    )
    ),
    "</email:adjuntos>"
    )
    ),
    "</email:solicitudEmail></email>",
    "</solicitud></solicitudUnicoType>"
    )
    )
    }

    The problem is the document, because the encodebase64string function corrupts the document sent.

    The HTTP REQUEST sent is:

    {"sourceApp":"TESORERIA","destinationApp":"PUSH","singleMessage":"PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/Pjxzb2xpY2l0dWRVbmljb1R5cGUgeG1sbnM6eHNpPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxL1hNTFNjaGVtYS1pbnN0YW5jZSIgeG1sbnM6c21zPSJTTVNCdXMiIHhtbG5zOmVtYWlsPSJlbWFpbCIgeG1sbnM6cHVzaD0icHVzaCI+PHNvbGljaXR1ZD48ZW52aW9PYmxpZ2Fkbz5FTUFJTDwvZW52aW9PYmxpZ2Fkbz48ZW1haWw+PGVtYWlsOnNvbGljaXR1ZEVtYWlsPjxlbWFpbDpjb2RpZ29QZXRpY2lvbj5QUlVFQkFQUkUxMjM8L2VtYWlsOmNvZGlnb1BldGljaW9uPjxlbWFpbDpkZXN0aW5hdGFyaW9zIGVtYWlsVW5pY289IlMiPgo8ZW1haWw6ZGVzdGluYXRhcmlvPmxmcHJhZG9zQG1pbnNhaXQuY29tPC9lbWFpbDpkZXN0aW5hdGFyaW8+PC9lbWFpbDpkZXN0aW5hdGFyaW9zPjxlbWFpbDpwbGFudGlsbGEgY29kaWdvPSJURVNPUkVSSUEtTk9USUZJQ0FDSU9OIj48L2VtYWlsOnBsYW50aWxsYT48ZW1haWw6YXN1bnRvPlBydWViYSBub3RpZmljYWNpw7NuIGNhbWJpbyBkZSBlc3RhZG88L2VtYWlsOmFzdW50bz48ZW1haWw6Y3VlcnBvPkVzdGltYWRvIHVzdWFyaW8sJmx0O2JyJmd0OyZsdDticiZndDtTZSBsZSBpbmZvcm1hIGRlIHF1ZSBsYSBzb2xpY2l0dWQgJmx0O2ImZ3Q7MDAwMDAwMDEmbHQ7L2ImZ3Q7IHNlIGVuY3VlbnRyYSBlbiBlc3RhZG8gJmx0O2kmZ3Q7J0F1dG9yaXphZG8sIHBlbmRpZW50ZSBkZSB2YWxpZGFjaSZhbXA7b2FjdXRlO24nJmx0Oy9pJmd0Oy4gQWNjZWRhIGFsIFBvcnRhbCBlbiBlbCBzaWd1aWVudGUgZW5sYWNlOiAmbHQ7YnImZ3Q7Jmx0O2JyJmd0O2h0dHBzOi8vY3NlY3QtZGV2LmFwcGlhbmNsb3VkLmNvbS9zdWl0ZS9kZXNpZ24mbHQ7YnImZ3Q7Jmx0O2JyJmd0O1VuIHNhbHVkby48L2VtYWlsOmN1ZXJwbz48ZW1haWw6YWRqdW50b3M+PGVtYWlsOmFkanVudG8gaWQ9ImlkRWplbXBsbyIgbm9tYnJlPSJQcnVlYmEgLSBjb3BpYSAtIGNvcGlhLnBkZiIgZXh0ZW5zaW9uPSJwZGYiPltEb2N1bWVudDo5Mzk5XTwvZW1haWw6YWRqdW50bz48L2VtYWlsOmFkanVudG9zPjwvZW1haWw6c29saWNpdHVkRW1haWw+PC9lbWFpbD48L3NvbGljaXR1ZD48L3NvbGljaXR1ZFVuaWNvVHlwZT4="}

    Thanks and regards.

     

  • I don't understand how your code can works if the limit is reached and it clearly the case. Copy paste the singleMessage into a tool to decode the base64 and see what you have really into the message. 

Comment Children
  • You are right, it is not a problem of limitation. It seem the limitation is now more than 150 chars.

    When I decode your base64, I can see "[Document:9399]" in your message. It is probably not you want.

    You try to put the document content by just setting fv!item. It cannot work.

    You must read the file content.and put the result inside. You can use the function readtextfromfile that is provided by the plugin Text File Utilities.

    The XML itself seem well formatted. I don't see any XML syntax error.

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?><solicitudUnicoType xmlns:xsi="">www.w3.org/.../XMLSchema-instance" xmlns:sms="SMSBus" xmlns:email="email" xmlns:push="push">
    <solicitud>
    <envioObligado>EMAIL</envioObligado>
    <email>
    <email:solicitudEmail>
    <email:codigoPeticion>PRUEBAPRE123</email:codigoPeticion>
    <email:destinatarios emailUnico="S">
    <email:destinatario>lfprados@minsait.com</email:destinatario>
    </email:destinatarios>
    <email:plantilla codigo="TESORERIA-NOTIFICACION"/>
    <email:asunto>Prueba notificación cambio de estado</email:asunto>
    <email:cuerpo>Estimado usuario,&lt;br&gt;&lt;br&gt;Se le informa de que la solicitud &lt;b&gt;00000001&lt;/b&gt; se encuentra en estado &lt;i&gt;'Autorizado, pendiente de validaci&amp;oacute;n'&lt;/i&gt;. Acceda al Portal en el siguiente enlace: &lt;br&gt;&lt;br&gt;csect-dev.appiancloud.com/.../design&lt;br&gt;&lt;br&gt;Un saludo.</email:cuerpo>
    <email:adjuntos>
    <email:adjunto id="idEjemplo" nombre="Prueba - copia - copia.pdf" extension="pdf">[Document:9399]</email:adjunto>
    </email:adjuntos>
    </email:solicitudEmail>
    </email>
    </solicitud>
    </solicitudUnicoType>

  • I know what I have really into the message.

    The request code is:

    {
    sourceApp: cons!ARQ_GNM_VALOR_SOURCE_APP,
    destinationApp: cons!ARQ_GNM_VALOR_DESTINATION_APP,
    singleMessage:
    encodebase64string(
    concat(
    "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>",
    "<solicitudUnicoType xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:sms=""SMSBus"" xmlns:email=""email"" xmlns:push=""push"">",
    "<solicitud><envioObligado>",
    /*(Opcional) Indicar si se debe realizar la comunicación solamente por una vía de envío: SMS, EMAIL, PUSH sin contingencias*/
    "EMAIL",
    "</envioObligado>",
    "<email><email:solicitudEmail><email:codigoPeticion>",
    ri!codigoPeticion,
    "</email:codigoPeticion><email:destinatarios emailUnico=""",
    cons!ARQ_GNM_VALOR_EMAIL_UNICO,
    """>",
    /*Destinatarios*/
    joinarray(
    a!forEach(
    items: ri!arrayDestinatarios,
    expression: char(10) & "<email:destinatario>" & fv!item & "</email:destinatario>"
    ),
    ""
    ),
    "</email:destinatarios><email:plantilla codigo=""",
    cons!ARQ_GNM_VALOR_CODIGO_PLANTILLA,
    """></email:plantilla><email:asunto>",
    ri!asunto,
    "</email:asunto><email:cuerpo>",
    toHtml(ri!cuerpo),
    "</email:cuerpo>",
    if(
    a!isNullOrEmpty(ri!adjuntos),
    null,
    concat(
    "<email:adjuntos>",
    a!forEach(
    items: ri!adjuntos,
    expression: concat(
    "<email:adjunto id=""idEjemplo"" nombre=""",
    document(fv!item, "name") & "." & document(fv!item, "extension"),
    """ extension=""pdf"">",
    fv!item,
    "</email:adjunto>"
    )
    ),
    "</email:adjuntos>"
    )
    ),
    "</email:solicitudEmail></email>",
    "</solicitud></solicitudUnicoType>"
    )
    )
    }

    The problem is the document, because the encodebase64string function corrupts the document sent.

    The HTTP REQUEST sent is:

    {"sourceApp":"TESORERIA","destinationApp":"PUSH","singleMessage":"PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/Pjxzb2xpY2l0dWRVbmljb1R5cGUgeG1sbnM6eHNpPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxL1hNTFNjaGVtYS1pbnN0YW5jZSIgeG1sbnM6c21zPSJTTVNCdXMiIHhtbG5zOmVtYWlsPSJlbWFpbCIgeG1sbnM6cHVzaD0icHVzaCI+PHNvbGljaXR1ZD48ZW52aW9PYmxpZ2Fkbz5FTUFJTDwvZW52aW9PYmxpZ2Fkbz48ZW1haWw+PGVtYWlsOnNvbGljaXR1ZEVtYWlsPjxlbWFpbDpjb2RpZ29QZXRpY2lvbj5QUlVFQkFQUkUxMjM8L2VtYWlsOmNvZGlnb1BldGljaW9uPjxlbWFpbDpkZXN0aW5hdGFyaW9zIGVtYWlsVW5pY289IlMiPgo8ZW1haWw6ZGVzdGluYXRhcmlvPmxmcHJhZG9zQG1pbnNhaXQuY29tPC9lbWFpbDpkZXN0aW5hdGFyaW8+PC9lbWFpbDpkZXN0aW5hdGFyaW9zPjxlbWFpbDpwbGFudGlsbGEgY29kaWdvPSJURVNPUkVSSUEtTk9USUZJQ0FDSU9OIj48L2VtYWlsOnBsYW50aWxsYT48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