When trying to use the kXML-RPC library for accessing services with RPC from a J2ME device, I kept getting this error (stacktrace taken from console output):
org.kxml.io.ParseException: unexpected: ParseEvent type=256 text='
' @-1:-1
at org.kxml.parser.AbstractXmlParser.read(+53)
at org.kxmlrpc.XmlRpcParser.parseValue(+54)
at org.kxmlrpc.XmlRpcParser.parseArray(+23)
at org.kxmlrpc.XmlRpcParser.parseValue(+280)
at org.kxmlrpc.XmlRpcParser.parseParams(+46)
at org.kxmlrpc.XmlRpcParser.parseResponse(+144)
at org.kxmlrpc.XmlRpcClient.execute(+200)
After a bit of investigating, I've figured out that the problem is that the parsing of XML-RPC responses are not removing all the whitespace between certain messages. To fix this, get the source of kXML-RPC and add the following line to XmlRpcParser.java as the first line of the parseValue() method:
parser.skip();
I also noticed that the parsing of arrays also throws up errors. The current version of the code fails to account for the <data> tags that are present inside the <array> tags. Add the following lines to the beginning of the parseArray() method, again found in XmlRpcParser.java:
parser.read(Xml.START_TAG, "", "data");
parser.skip();
and the following lines to the end of parseArray() before the return statement:
parser.read(Xml.END_TAG, "", "data");
parser.skip();
That should do it! I might upload the modified source code to my files, but I need to review the license on the original code first (if I can be bothered). Does anybody know much about the Enhyrda Public License?