DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17665>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17665

XML-RPC client doesn't handle the enconding specified by the XmlRpc.setEncoding() 
method

           Summary: XML-RPC client doesn't handle the enconding specified by
                    the XmlRpc.setEncoding() method
           Product: XML-RPC
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Source
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


I'm using the Apache XML-RPC 1.1 library but it seems that the 
XmlRpcClient doesn't handle the encoding specified by the XmlRpc.setEncoding() 
method

I have written a XmlRpcServer using UTF-8 encoding.
A call to XmlRpc.setEncoding("UTF8") enables to set it.
The server works perfectly and returns UTF-8

On my client side, I do the same : I set the encoding using the 
XmlRpc.setEncoding() method. But it doesn't work, I can't read UTF-8 from my 
server.

I've watched the source code.
The stream opened in the XmlRpc.parse(InputStream is) method doesn't 
care about the setted encoding.
So, I've modified this piece of code and, now, it works properly.

This is the code I've modified :

/**
* Parse the input stream. For each root level object, method
* Modified on 13/01/2003 to handle encoding specified by the 
XmlRpc.setEncoding() method
* <code>objectParsed</code> is called.
*/
synchronized void parse (InputStream is)
throws Exception
{
// reset values (XmlRpc objects are reusable)
errorLevel = NONE;
errorMsg = null;
values = new Stack ();
if (cdata == null)
{
cdata = new StringBuffer (128);
}
else
{
cdata.setLength (0);
}
readCdata = false;
currentValue = null;

long now = System.currentTimeMillis ();

// Initializes parser
...

Parser parser = null;
try
{
parser = (Parser) parserClass.newInstance ();
}
catch (NoSuchMethodError nsm)
{
// This is thrown if no constructor exists for the parser 
class
// and is transformed into a regular exception.
throw new Exception ("Can't create Parser: " + 
parserClass);
}

parser.setDocumentHandler (this);
parser.setErrorHandler (this);

if (debug)
System.err.println("Beginning parsing XML input stream");

// BEFORE : ORIGINAL CODE
// parser.parse (new InputSource (is));

// AFTER : Modified by Klopp Gérald to take in charge 
encoding specified
// by the XmlRpc.setEnconding() method
parser.parse( new InputSource( new InputStreamReader
(is,getEncoding()) ) );

if (debug)
System.err.println ("Spent "+
(System.currentTimeMillis () - now) + " millis 
parsing");
}


Can you tell me more about this problem? Is this a bug?

Thank you,
Gérald Klopp

Reply via email to