You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by John Baker <jb...@javasystemsolutions.com> on 2009/04/27 20:37:00 UTC

CXF, Unicode, utf8, encoding issue

Hi,

I'm looking at Unicode characters returned via a webservice call.  The common 
encoding scenerio - it works for me, where a CXF generated client can make a 
WS call, the WS call returns a String containing Unicode characters, and the 
client converts them correctly.  However for someone in the US, it doesn't 
work.

Here's a sample out message:

INFO: Outbound Message
---------------------------
Encoding: UTF-8
Headers: {}
Messages:
Payload: <soap:Envelope 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:queryResponse 
xmlns:ns1="http://services.integration.javasystemsolutions.com/"><return>
      &lt;shortDescription&gt;àèìòù!&quot;
£$&amp;amp;/()=?^@[]#|!&lt;/shortDescription&gt;;
</return></ns1:queryResponse></soap:Body></soap:Envelope>

(I'm returning a String that contains some XML.)

I guess I'm wondering if this is acceptable?  If the client interprets that 
String as utf-8, should there be no problem?

I've used wsmonitor to check the response from CXF and it definitely includes 
the utf-8 encoding:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>

(etc.)

The client experiencing problems is .NET.


John

Re: CXF, Unicode, utf8, encoding issue

Posted by Daniel Kulp <dk...@apache.org>.
That soap message definitely all looks correct and perfectly valid.   Possibly 
double check the Content-Type header on the HTTP level using your monitor to 
make sure the proper charset is there as well.   

For the most part, that should "just work" and is kind of surprising that .NET 
cannot handle it.

Dan


On Mon April 27 2009 2:37:00 pm John Baker wrote:
> Hi,
>
> I'm looking at Unicode characters returned via a webservice call.  The
> common encoding scenerio - it works for me, where a CXF generated client
> can make a WS call, the WS call returns a String containing Unicode
> characters, and the client converts them correctly.  However for someone in
> the US, it doesn't work.
>
> Here's a sample out message:
>
> INFO: Outbound Message
> ---------------------------
> Encoding: UTF-8
> Headers: {}
> Messages:
> Payload: <soap:Envelope
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:quer
>yResponse
> xmlns:ns1="http://services.integration.javasystemsolutions.com/"><return>
> &lt;shortDescription&gt;àèìòù!&quot;
> £$&amp;amp;/()=?^@[]#|!&lt;/shortDescription&gt;;
> </return></ns1:queryResponse></soap:Body></soap:Envelope>
>
> (I'm returning a String that contains some XML.)
>
> I guess I'm wondering if this is acceptable?  If the client interprets that
> String as utf-8, should there be no problem?
>
> I've used wsmonitor to check the response from CXF and it definitely
> includes the utf-8 encoding:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
>     <soap:Body>
>
> (etc.)
>
> The client experiencing problems is .NET.
>
>
> John

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog