You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlrpc-dev@ws.apache.org by Praveen Udawat <pr...@gmo.jp> on 2002/11/22 09:25:15 UTC
Encoding Problem for Japanese Character set
Hi All,
I am implmenting XMLRPC server as a servlet in my project.
I am also using the RPC client provided with the apache source.
I want to use the UTF-8 character set for both server and client
communication.
Even after that, the data stored in database has got corrupted.
Is anybody having any tips or experience about it???
I have set the character set at server side as follows;
public void doPost(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException
{
XmlRpc.encoding="UTF-8";
XmlRpc.debug=true;
XmlRpcServer xmlrpc = new XmlRpcServer ();
xmlrpc.addHandler ("$default", new RemoteMethod());
byte[] result = xmlrpc.execute (req.getInputStream ());
res.setContentType("text/html; charset=UTF-8");
res.setContentLength (result.length);
OutputStream output = res.getOutputStream();
output.write (result);
output.flush ();
}
The client side code are as follows:
package org.apache.xmlrpc;
import java.util.Vector;
import java.net.URL;
import java.io.*;
public class RegistClient
{
// the xml-rpc client
XmlRpcClient client;
/**
* main method
*/
public static void main (String args[]) throws Exception
{
RegistClient client = new RegistClient
("http://192.168.38.51/oem/servlet/XmlRpcServlet");
client.run ();
}
/**
* Constructor
*/
public RegistClient (String url) throws Exception
{
client = new XmlRpcClient (url);
}
/**
* Read from standard input and make an asynchronous XML-RPC call.
*/
public void run () throws IOException
{
String token = null;
BufferedReader d = new BufferedReader(new InputStreamReader(System.in));
Vector v = new Vector ();
XmlRpc.encoding="UTF-8";
//prepare arguments for RegistCustomer Method
v.add ("Onamae");
v.add ("CustomerID001");
v.add ("rpctest@setsuzoku.jp");
v.add ("Praveen");
v.add ("Udawat");
v.add ("ウダワット");
v.add ("プらビーン");
v.add ("150-0045");
v.add ("東京部");
v.add ("渋谷区");
v.add ("17−14−202神泉町");
v.add ("03-3464-7574");
v.add ("");
v.add ("08050297299");
try
{
Object result = client.execute ("RegistCustomer", v);
System.err.println ("received: "+result);
}
catch (Exception exception)
{
System.err.println ("Error: "+exception);
}
}
}