1. Thinking: Using the J2ME itself with the Httpconnection access WebService, call the Http://localhost/RoadWebService/RoadWS.asmx/method WebServiceTest, parameter is param. As follows:
Here is the right to the string s for XML parsing.
Items = Parseusingkxml (s);
Mdisplay.setcurrent (new ItemList (items));
}
This time the stream to the string is in XML format, as follows: Hello ZL
Using a third party's CLDC environment, the open source XML parser ──kxml, download the Kxml package from the http://www.kxml.org/. The data stream in the obtained XML format is parsed by the following methods:
Private string[] Parseusingkxml (String XML) {
try {
Bytearrayinputstream bin =
New Bytearrayinputstream (
Xml.getbytes ());
InputStreamReader in = new InputStreamReader (BIN);
Class ItemList extends List implements Commandlistener {
ItemList (string[] list) {
Super ("Items", implicit, list, null);
AddCommand (Mexitcommand);
Setcommandlistener (this);
}
public void Commandaction (Command C, displayable D) {
if (c = = Mexitcommand) {
Exitmidlet ();
}
}
}
}
Use wtk2.0 to build project with the name Httpmidlet, class name Httpmidlet
Copy the Httpmidlet.java file to the Apps\httpmidlet src directory under the WTK directory, and copy the third party Kxml file ksoap-midp.zip to the Apps\ directory and compile it.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.