2

请您帮我以 WBXML 格式将数据从移动应用程序发送到 Web 服务器?我有一点将 xml 转换为 wbxml,但没有得到如何以有效的方式将其发送到 Web 服务器?

4

1 回答 1

1

I'm not sure I fully understand your question but here goes...

You need to use a POST HTTP request, and write the WBXML data to the connection objects output stream. Here is a brief example, obviously you'll need more code for it to actually work:

byte[] wbxml = getMyWbxmlData();
HttpConnection conn = (HttpConnection)Connector.open("http://myserver.com/mywbxmlhandler");
conn.setRequestMethod(HttpConnection.POST);
OutputStream output = conn.openOutputStream();
output.write(wbxml);
InputStream input = conn.openInputStream(); // This will flush the outputstream
// Do response processing

That is all assuming your WBXML already includes the preamble, such as version number, public code page identifier etc.

于 2008-09-26T13:50:23.727 回答