ws-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From August Mueller <...@mu.org>
Subject Re: getting back utf-8 data via xmlrpc call
Date Sat, 20 Sep 2003 15:41:48 GMT
On 9/19/03 8:05 PM, "Walter Christian" <wolti@sil.at> wrote:

> 
> Hello,
> 
>> I've got a servlet that I'm using with XmlRpcServer to call a class via
>> xml-rpc.  I'm sending utf-8 data to it, and that's working fine, but
>> when I try and get utf data back out, it comes out garbled in the areas
>> where there were multi-byte chars... I fear I'm doing something wrong.
>> 
>> I've already called XmlRpc.setEncoding("UTF-8"); in my servlet's init
>> method...
> 
> I am doing exactly the same thing. It seems that setEncoding only works
> correct for sending data. Every xml response I receive which is encoded
> by UTF-8 also get garbled.
> I solved this problem by setting -Dfile.encoding=UTF8 and now I get
> correct results. But this is of course also only a temporary solution.

I haven't tried that... I might see what that gets me.
What I ended up doing was this:

res.setContentType("text/xml; charset=UTF-8");

byte[] result = xmlrpc.execute(req.getInputStream());
PrintStream out = new PrintStream(res.getOutputStream());
out.println(new String(result, "utf-8"));
out.close();



I however, could not send the content-length because it was generating
incorrect results after the PrintStream was done with it.

//res.setContentLength(result.length);


I'm not 100% sure this is the correct solution, but it seems to work.

Thanks,

-gus

--  
August Mueller
http://flyingmeat.com/
VoodooPad - 1st Place U.S., Second O'Reilly Mac OS X Innovaters Contest
"Christmas means carnage!"  -- Ferdinand, the duck



Mime
View raw message