cancel
Showing results for 
Search instead for 
Did you mean: 

UTF-8 via SOAP

tim-erwin
Champ in-the-making
Champ in-the-making
Hi,

I'm using the alfresco web services and have the problem that I don't get UTF-8 encoded text. For instance when I create a file with the name "Łódź.txt" in the alfresco webclient it is displayed correctly (database and connection are properly configured) but the Java webservice client returns "?ód?.txt" as name. The PHP webservice client gets it right.

I had a look at the SOAP response with Wireshark and it showed that "Ł", "ó" and "ź" are encoded as "&#<unicodeCodePoint>;"  (e.g. &#141; for Ł). Hence, the problem is not the encoding of the response itself but there must be some decoding on the client side which for some reason produces Latin-1 instead of UTF-8.

How can I make axis or the alfresco webclient to give me UTF-8 encoded text?

Thanks
Tim
1 REPLY 1

tim-erwin
Champ in-the-making
Champ in-the-making
Well, this was neither an axis problem nor an alfresco one. Tomcat for some reason uses latin-1 as default encoding for responses and writing to file (two separate problems actually, which appeared to be connected). I fixed it by setting the Java option -Dfile.encoding=utf-8 and putting this in the code:

if (req.getCharacterEncoding() == null)
   req.setCharacterEncoding("UTF-8");
res.setContentType("text/html; charset=UTF-8");
res.setCharacterEncoding("UTF-8");

Cheers
Tim