axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gergana Georgieva (JIRA)" <>
Subject [jira] [Commented] (AXIS2-4309) JSONMessageFormatter isnt using the correct charset encoding
Date Tue, 21 Jun 2011 07:13:47 GMT


Gergana Georgieva commented on AXIS2-4309:

I have tested those changes and I have found that on several places in
and you call String.getBytes method without any encoding.
Since on my machine the default encoding is not UTF-8 this breaks the JSON formatting.

I have corrected all calls of String.getBytes to use the encoding that comes from the message
context and with this change the JSON formatter works correctly.

I have attached test request in the ticket. (xml-9-jp.xml)

Best regards,

> JSONMessageFormatter isnt using the correct charset encoding
> ------------------------------------------------------------
>                 Key: AXIS2-4309
>                 URL:
>             Project: Axis2
>          Issue Type: Bug
>    Affects Versions: 1.4.1
>            Reporter: Johannes Wagener
>            Assignee: Andreas Veithen
>             Fix For: 1.6.0
>         Attachments: xml-9-jp.xml
> When using JSONMessageFormatter, i had some trouble with german umlauts. The response
wasnt in the correct encoding (UTF-8)
> After debugging for while, i found out that getJSONWriter in
> is ignoring the requested charset encoding:
>     protected XMLStreamWriter getJSONWriter(OutputStream outStream) {
>         return new BadgerFishXMLStreamWriter(new OutputStreamWriter(outStream));
>     }
> In my case outputStreamWriter was writing in CP819 (or something like that), while the
response had a   
> Content-Type: application/json;charset=UTF-8
> so i changed it to:
>     protected XMLStreamWriter getJSONWriter(OutputStream outStream,Charset charset) {
>         return new BadgerFishXMLStreamWriter(new OutputStreamWriter(outStream, charset));
>     }
> when calling getJSONWriter i used:
>  Charset charset = Charset.forName(format.getCharSetEncoding());                    
>  XMLStreamWriter jsonWriter = getJSONWriter(out,charset);
> and catching the UnsupportedEncodingException.
> After changing these 2 files, everything worked as expected.

This message is automatically generated by JIRA.
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message