File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Parsing WBXML POSt Request Data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Parsing WBXML POSt Request Data" Watch "Parsing WBXML POSt Request Data" New topic

Parsing WBXML POSt Request Data

Maneesha Patel

Joined: Nov 15, 2007
Posts: 1
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 id 54 undef.
I get " 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

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13025

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.

I agree. Here's the link:
subject: Parsing WBXML POSt Request Data
It's not a secret anymore!