Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

203
Vistas
Is there any javascript option to make encoded-string as UTF-8 in WSO2 Script mediator?

I'm trying to convert incoming encoded(RSA) string values to UTF-8 in the WSO2 EI 6.6.0 Script Mediator mediator.

Incoming Request:

{
    "result": {
        "message": ".eJwdy00OwiAQBtC7zFqS4Ufg8zLNUIaGDZjaxoXx7ja-_fvQc751X3qlB2Wp4kKCU47BZy4A7pa9uuitqNKN5t63PuToY1vO87-wri02gSlSiwloMKhcDZxoSClDAl-zj9exjHkFy0zfH5pUI3w.YfvMdQ.GcmMQuY3BN33JATAfFB3ZyeXO8U"
    }
}

By using script mediator trying to convert above message content into utf-8.

Code:

<property expression="json-eval($.result.message)" name="input" scope="default" type="STRING"/>
<script language="js"><![CDATA[var id = parseInt(mc.getProperty("input"));
                var encoded_id  = utf8.encode(id); 
                mc.setProperty("encoded_id", encoded_id );]]></script>
            <log level="custom">
                <property expression="get-property('encoded_id')" name="encoded_id"/>
            </log>

Facing below error:

[2022-02-07 13:05:32,279] ERROR {ScriptMediator} - {api:utf8enc} The script engine returned an error executing the inlined js script function mediate com.sun.phobos.script.util.ExtendedScriptException: org.mozilla.javascript.EcmaError: ReferenceError: "utf8" is not defined. (<Unknown Source>#2) in <Unknown Source> at line number 2

May I know the way to convert the encoded value to UTF-8 by using javascript functionality?

Note: expecting to shorten the above lengthy value(substring shouldn't be used here) after convert it into utf-8?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda