Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parsing WBXML POSt Request Data

 
Maneesha Patel
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I want to read WBXML formatted SyncML data sent by a Mobile Device
There is a servlets at server side which receives the http request of the
device and tries to read the contents of the POST request data by using .
Request.getInputStream(); method....
I then Pass this data to a method "wbxmlToXml(req.getInputStream().toString().getBytes()) "
I am using kxml as XML parsing the Initial Lines of the method are as following
"
public static String wbxmlToXml(byte[] wbxml) throws IOException {
String xml = null;
try {
// Construct an InputStream on byte[] to be used by WbxmlParser
ByteArrayInputStream in = new ByteArrayInputStream(wbxml);
AbstractXmlParser parser; //org.kxml.parser.AbstractXmlParser
parser = new WbxmlParser(in);
// Construct a DOM Document to parse WBXML
Document document = new Document();
document.parse(parser);------------------> Error :java.io.IOException: id 54 undef.
....
.....
"
I get "java.io.IOException: id 54 undef." error as mentioned above.

Please somebody guide regarding this problem or som,e other way to parse the WBXML format from Streamed Post Data

Regards,
Maneesha
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Why are you trying to convert to byte[]? XML is always unicode characters - changing back and forth runs the risk of a bad character conversion creating an illegal character.

I don't know about the library you are using but the standard Java library parser is happy with an InputStream created from a String.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic