|
| <prev next> |
problem when transfer wbxml information between j2me client and j2ee server: msg#00000java.enhydra.kxml
Hi,everyone,I am developing a project based on the j2me and j2ee.I encounter a problem when I want to use wbxml as the message format transfered between the j2me client and servlet.My code follows the code in the article "Compressing XML for Faster Wireless Networking" (http://developers.sun.com/techtopics/mobility/midp/ttips/compressxml/) The code of my client is as follows: private static final String tagTable[] = { "accountInfo", "accountName", "passWord", "personID", "mobilePhone", "e_mail" }; con =(HttpConnection) Connector.open( "http://127.0.0.1:28080/webmodule/servlet/account"); con.setRequestMethod(HttpConnection.POST); out = con.openOutputStream(); out.flush(); xmlWriter = new WbxmlWriter(out); xmlWriter.setTagTable(0, tagTable); xmlWriter.startTag("accountInfo"); xmlWriter.startTag("accountName"); xmlWriter.write(accountName); xmlWriter.endTag(); ......................................................... The server code of my server is as follows: in request.getInputStream(); parser = new WbxmlParser(in); ParseEvent event = null; parser.setTagTable(0, tagTable); do { try { event = parser.read(); if ((Xml.START_TAG == event.getType()) && (event.getName().equalsIgnoreCase("accountName"))) { if (Xml.TEXT == (event = parser.read()).getType()) { accountName = event.getText(); } } .............................................. But I find that I get an exception when the client trid to send the message to the servlet. The exception information is below: java.io.IOException: Unexpected EOF at org.kxml.wap.WbxmlParser.readByte(Unknown Source) at org.kxml.wap.WbxmlParser.readInt(Unknown Source) at org.kxml.wap.WbxmlParser.<init>(Unknown Source) at server.web.Accountlet.doGet(Accountlet.java:86) I am confused by the exception . So I checked the source code of kXML1.21. I think that the problem may be inside the constructor of wbxmlparser. The code of constructor of wbxmlparser is below: this.in = in; version = readByte (); publicIdentifierId = readInt (); if (publicIdentifierId == 0) readInt (); charSet = readInt (); // skip charset //Notice the problem may be here int strTabSize = readInt (); StringBuffer buf = new StringBuffer (strTabSize); for (int i = 0; i < strTabSize; i++) buf.append ((char) readByte ()); stringTable = buf.toString (); The wbxmlwriter only writer three binary number in the constructor: out.write (0x01); // version out.write (0x01); // unknown or missing public identifier out.write (0x04); // iso-8859-1 But the wbxmlparser need more than three binary numbers.So the function readByte() called by the function readInt() throws the Exception mentioned above. I don't know the use of strTabSize .It seems the client must write more binary number to the stream. Does anyone can tell me the right code(both the client and the server) to transfer wbxml information between client and server? Or tell me how to write the code correctly? Do I really need to learn the knowledge of what the binary number stands for(such as 0x01 stands for something ,0x03 stands for something)? I think the knowledge of encoding with wbxml should be transparent to the users. Any idea or suggestion is highly appreciated. Thank you! Best regards! Benny Young _________________________________________________________________ 免费下载 MSN Explorer: http://explorer.msn.com/lccn/
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Next by Date: | Proposed fixes to support "multiple code pages" for WBXML documents, Christian Kurzke |
|---|---|
| Next by Thread: | Proposed fixes to support "multiple code pages" for WBXML documents, Christian Kurzke |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |