You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Daniel Langevin <an...@gmail.com> on 2021/09/14 17:46:44 UTC

Try to Convert Unicode UTF-8 Encoding / CAMEL 3.x

Hi all,

Here is my case,
i have a body containing some Unicode characters, this body is the RESPONSE of a JDBC connection Query.

In camel 2.x i was using xmljson to convert Unicode data into UTF-8 encoding.

i try to convert this service to camel 3.X but xmljson is deprecated and don,t find another way.

Someone as a clue to achieve this by another way.

Thank's 


Daniel


==========================================================================
Here how i achieved this in camel 2.x to convert Special Unicode Character to UTF-8 encoding.

<to uri="XXXoracleSqlStored:XXX_pkb_apx_service_ords.p_verif_ident(VARCHAR ${header.XXXCodepgm}, VARCHAR ${headers.XXXid}, OUT VARCHAR jsonString)" /> <setBody><simple>${body[jsonString]}</simple></setBody>
<!-- convert UTF-8  XML -->
<unmarshal><xmljson encoding="UTF-8"/><unmarshal>
<!-- goback to JSON converted -->
<marshal><xmljson encoding="UTF-8"/><marshal>


Explanation:

<to uri="XXXoracleSqlStored:XXX_pkb_apx_service_ords.p_verif_ident(VARCHAR ${header.XXXCodepgm}, VARCHAR ${headers.XXXid}, OUT VARCHAR jsonString)" />

BODY CONTENT (type : java.util.LinkedHashMap ) {jsonString={
"codeRetour":200
,"msgRetour":"succes"
,"msgCourt":"L\u0027identification a r\u00E9ussi."
,"msgLong":"L\u0027identification du dossier du client a r\u00E9ussi."
}
}


Retrieving jsonString content in the Body <setBody><simple>${body[jsonString]}</simple></setBody>

BODY CONTENT (type : java.lang.String)
{
"codeRetour":200
,"msgRetour":"succes"
,"msgCourt":"L\u0027identification a r\u00E9ussi."
,"msgLong":"L\u0027identification du dossier du client a r\u00E9ussi."
}


Unmarshal to XML with jsonxml to convert unicode character with UTF-8

<unmarshal><xmljson encoding="UTF-8"/><unmarshal> BODY CONTENT:
<?xml version="1.0" encoding="UTF-8"?>
<o><codeRetour>200</codeRetour><msgCourt>L'identification du dossier du client a réussi.</msgCourt> <msgLong>L'identification du dossier du client a réussi.</msgLong><msgRetour>succes</msgRetour></o>

Marshal to JSON again with jsonxml.
<marshal><xmljson encoding="UTF-8"/><marshal> BODY CONTENT:
{"codeRetour":"200","msgCourt":"L'identification du dossier du client a réussi.", "msgLong":"L'identification du dossier du client a réussi.","msgRetour":"succes"}




Daniel Langevin


Re: Try to Convert Unicode UTF-8 Encoding / CAMEL 3.x

Posted by Alexandre Gallice <al...@gmail.com>.
Hey Great :)

On Fri, Sep 17, 2021 at 4:38 PM Daniel Langevin <an...@gmail.com>
wrote:

> Hi Alexandrfe,
>
> you are right it's work with camel-xj
>
> whith those lines:
> <setBody><simple>${body[jsonString]}</simple></setBody>
>  <to uri="xj:identity?transformDirection=JSON2XML" />
>  <to uri="xj:identity?transformDirection=XML2JSON" />
>
>
>
> Thank's
>
>
> Daniel
>
> On 2021/09/15 08:54:25, Alexandre Gallice <al...@gmail.com> wrote:
> > Never tested, but maybe camel-xj
> > https://camel.apache.org/components/3.7.x/xj-component.html ?
> >
> > On Wed, Sep 15, 2021 at 10:39 AM Daniel Langevin <an...@gmail.com>
> > wrote:
> >
> > > Hi all,
> > >
> > > Here is my case,
> > > i have a body containing some Unicode characters, this body is the
> > > RESPONSE of a JDBC connection Query.
> > >
> > > In camel 2.x i was using xmljson to convert Unicode data into UTF-8
> > > encoding.
> > >
> > > i try to convert this service to camel 3.X but xmljson is deprecated
> and
> > > don,t find another way.
> > >
> > > Someone as a clue to achieve this by another way.
> > >
> > > Thank's
> > >
> > >
> > > Daniel
> > >
> > >
> > >
> ==========================================================================
> > > Here how i achieved this in camel 2.x to convert Special Unicode
> Character
> > > to UTF-8 encoding.
> > >
> > > <to
> uri="XXXoracleSqlStored:XXX_pkb_apx_service_ords.p_verif_ident(VARCHAR
> > > ${header.XXXCodepgm}, VARCHAR ${headers.XXXid}, OUT VARCHAR
> jsonString)" />
> > > <setBody><simple>${body[jsonString]}</simple></setBody>
> > > <!-- convert UTF-8  XML -->
> > > <unmarshal><xmljson encoding="UTF-8"/><unmarshal>
> > > <!-- goback to JSON converted -->
> > > <marshal><xmljson encoding="UTF-8"/><marshal>
> > >
> > >
> > > Explanation:
> > >
> > > <to
> uri="XXXoracleSqlStored:XXX_pkb_apx_service_ords.p_verif_ident(VARCHAR
> > > ${header.XXXCodepgm}, VARCHAR ${headers.XXXid}, OUT VARCHAR
> jsonString)" />
> > >
> > > BODY CONTENT (type : java.util.LinkedHashMap ) {jsonString={
> > > "codeRetour":200
> > > ,"msgRetour":"succes"
> > > ,"msgCourt":"L\u0027identification a r\u00E9ussi."
> > > ,"msgLong":"L\u0027identification du dossier du client a r\u00E9ussi."
> > > }
> > > }
> > >
> > >
> > > Retrieving jsonString content in the Body
> > > <setBody><simple>${body[jsonString]}</simple></setBody>
> > >
> > > BODY CONTENT (type : java.lang.String)
> > > {
> > > "codeRetour":200
> > > ,"msgRetour":"succes"
> > > ,"msgCourt":"L\u0027identification a r\u00E9ussi."
> > > ,"msgLong":"L\u0027identification du dossier du client a r\u00E9ussi."
> > > }
> > >
> > >
> > > Unmarshal to XML with jsonxml to convert unicode character with UTF-8
> > >
> > > <unmarshal><xmljson encoding="UTF-8"/><unmarshal> BODY CONTENT:
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <o><codeRetour>200</codeRetour><msgCourt>L'identification du dossier du
> > > client a réussi.</msgCourt> <msgLong>L'identification du dossier du
> client
> > > a réussi.</msgLong><msgRetour>succes</msgRetour></o>
> > >
> > > Marshal to JSON again with jsonxml.
> > > <marshal><xmljson encoding="UTF-8"/><marshal> BODY CONTENT:
> > > {"codeRetour":"200","msgCourt":"L'identification du dossier du client a
> > > réussi.", "msgLong":"L'identification du dossier du client a
> > > réussi.","msgRetour":"succes"}
> > >
> > >
> > >
> > >
> > > Daniel Langevin
> > >
> > >
> >
>

Re: Try to Convert Unicode UTF-8 Encoding / CAMEL 3.x

Posted by Daniel Langevin <an...@gmail.com>.
Hi Alexandrfe,

you are right it's work with camel-xj

whith those lines:
<setBody><simple>${body[jsonString]}</simple></setBody>
 <to uri="xj:identity?transformDirection=JSON2XML" />
 <to uri="xj:identity?transformDirection=XML2JSON" />



Thank's


Daniel

On 2021/09/15 08:54:25, Alexandre Gallice <al...@gmail.com> wrote: 
> Never tested, but maybe camel-xj
> https://camel.apache.org/components/3.7.x/xj-component.html ?
> 
> On Wed, Sep 15, 2021 at 10:39 AM Daniel Langevin <an...@gmail.com>
> wrote:
> 
> > Hi all,
> >
> > Here is my case,
> > i have a body containing some Unicode characters, this body is the
> > RESPONSE of a JDBC connection Query.
> >
> > In camel 2.x i was using xmljson to convert Unicode data into UTF-8
> > encoding.
> >
> > i try to convert this service to camel 3.X but xmljson is deprecated and
> > don,t find another way.
> >
> > Someone as a clue to achieve this by another way.
> >
> > Thank's
> >
> >
> > Daniel
> >
> >
> > ==========================================================================
> > Here how i achieved this in camel 2.x to convert Special Unicode Character
> > to UTF-8 encoding.
> >
> > <to uri="XXXoracleSqlStored:XXX_pkb_apx_service_ords.p_verif_ident(VARCHAR
> > ${header.XXXCodepgm}, VARCHAR ${headers.XXXid}, OUT VARCHAR jsonString)" />
> > <setBody><simple>${body[jsonString]}</simple></setBody>
> > <!-- convert UTF-8  XML -->
> > <unmarshal><xmljson encoding="UTF-8"/><unmarshal>
> > <!-- goback to JSON converted -->
> > <marshal><xmljson encoding="UTF-8"/><marshal>
> >
> >
> > Explanation:
> >
> > <to uri="XXXoracleSqlStored:XXX_pkb_apx_service_ords.p_verif_ident(VARCHAR
> > ${header.XXXCodepgm}, VARCHAR ${headers.XXXid}, OUT VARCHAR jsonString)" />
> >
> > BODY CONTENT (type : java.util.LinkedHashMap ) {jsonString={
> > "codeRetour":200
> > ,"msgRetour":"succes"
> > ,"msgCourt":"L\u0027identification a r\u00E9ussi."
> > ,"msgLong":"L\u0027identification du dossier du client a r\u00E9ussi."
> > }
> > }
> >
> >
> > Retrieving jsonString content in the Body
> > <setBody><simple>${body[jsonString]}</simple></setBody>
> >
> > BODY CONTENT (type : java.lang.String)
> > {
> > "codeRetour":200
> > ,"msgRetour":"succes"
> > ,"msgCourt":"L\u0027identification a r\u00E9ussi."
> > ,"msgLong":"L\u0027identification du dossier du client a r\u00E9ussi."
> > }
> >
> >
> > Unmarshal to XML with jsonxml to convert unicode character with UTF-8
> >
> > <unmarshal><xmljson encoding="UTF-8"/><unmarshal> BODY CONTENT:
> > <?xml version="1.0" encoding="UTF-8"?>
> > <o><codeRetour>200</codeRetour><msgCourt>L'identification du dossier du
> > client a réussi.</msgCourt> <msgLong>L'identification du dossier du client
> > a réussi.</msgLong><msgRetour>succes</msgRetour></o>
> >
> > Marshal to JSON again with jsonxml.
> > <marshal><xmljson encoding="UTF-8"/><marshal> BODY CONTENT:
> > {"codeRetour":"200","msgCourt":"L'identification du dossier du client a
> > réussi.", "msgLong":"L'identification du dossier du client a
> > réussi.","msgRetour":"succes"}
> >
> >
> >
> >
> > Daniel Langevin
> >
> >
> 

Re: Try to Convert Unicode UTF-8 Encoding / CAMEL 3.x

Posted by Alexandre Gallice <al...@gmail.com>.
Never tested, but maybe camel-xj
https://camel.apache.org/components/3.7.x/xj-component.html ?

On Wed, Sep 15, 2021 at 10:39 AM Daniel Langevin <an...@gmail.com>
wrote:

> Hi all,
>
> Here is my case,
> i have a body containing some Unicode characters, this body is the
> RESPONSE of a JDBC connection Query.
>
> In camel 2.x i was using xmljson to convert Unicode data into UTF-8
> encoding.
>
> i try to convert this service to camel 3.X but xmljson is deprecated and
> don,t find another way.
>
> Someone as a clue to achieve this by another way.
>
> Thank's
>
>
> Daniel
>
>
> ==========================================================================
> Here how i achieved this in camel 2.x to convert Special Unicode Character
> to UTF-8 encoding.
>
> <to uri="XXXoracleSqlStored:XXX_pkb_apx_service_ords.p_verif_ident(VARCHAR
> ${header.XXXCodepgm}, VARCHAR ${headers.XXXid}, OUT VARCHAR jsonString)" />
> <setBody><simple>${body[jsonString]}</simple></setBody>
> <!-- convert UTF-8  XML -->
> <unmarshal><xmljson encoding="UTF-8"/><unmarshal>
> <!-- goback to JSON converted -->
> <marshal><xmljson encoding="UTF-8"/><marshal>
>
>
> Explanation:
>
> <to uri="XXXoracleSqlStored:XXX_pkb_apx_service_ords.p_verif_ident(VARCHAR
> ${header.XXXCodepgm}, VARCHAR ${headers.XXXid}, OUT VARCHAR jsonString)" />
>
> BODY CONTENT (type : java.util.LinkedHashMap ) {jsonString={
> "codeRetour":200
> ,"msgRetour":"succes"
> ,"msgCourt":"L\u0027identification a r\u00E9ussi."
> ,"msgLong":"L\u0027identification du dossier du client a r\u00E9ussi."
> }
> }
>
>
> Retrieving jsonString content in the Body
> <setBody><simple>${body[jsonString]}</simple></setBody>
>
> BODY CONTENT (type : java.lang.String)
> {
> "codeRetour":200
> ,"msgRetour":"succes"
> ,"msgCourt":"L\u0027identification a r\u00E9ussi."
> ,"msgLong":"L\u0027identification du dossier du client a r\u00E9ussi."
> }
>
>
> Unmarshal to XML with jsonxml to convert unicode character with UTF-8
>
> <unmarshal><xmljson encoding="UTF-8"/><unmarshal> BODY CONTENT:
> <?xml version="1.0" encoding="UTF-8"?>
> <o><codeRetour>200</codeRetour><msgCourt>L'identification du dossier du
> client a réussi.</msgCourt> <msgLong>L'identification du dossier du client
> a réussi.</msgLong><msgRetour>succes</msgRetour></o>
>
> Marshal to JSON again with jsonxml.
> <marshal><xmljson encoding="UTF-8"/><marshal> BODY CONTENT:
> {"codeRetour":"200","msgCourt":"L'identification du dossier du client a
> réussi.", "msgLong":"L'identification du dossier du client a
> réussi.","msgRetour":"succes"}
>
>
>
>
> Daniel Langevin
>
>