Listing 1: StockQuoteDemo MIDlet

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
import javax.microedition.io.*;
import org.ksoap.*;
import org.ksoap.http.*;

public class StockQuoteDemo extends MIDlet implements CommandListener {
Form mainForm = new Form ("StockQuotes");
TextField symbolField = new TextField ("Symbol", "SUNW", 5, 
TextField.ANY);
StringItem resultItem = new StringItem ("", "");
Command getCommand = new Command ("Get", Command.SCREEN, 1);
public StockQuoteDemo () {
mainForm.append (symbolField);
mainForm.append (resultItem);
mainForm.addCommand (getCommand);
mainForm.setCommandListener (this);
}
public void startApp () {
Display.getDisplay (this).setCurrent (mainForm);
}
public void pauseApp () {
}
public void destroyApp (boolean unconditional) {

public void commandAction (Command c, Displayable d) {
try {
// Build request string
String symbol = symbolField.getString ();
resultItem.setLabel (symbol);
// Create a SoapObject by specifying the URN and the method name 
// of the SOAP RPC Web Service.
SoapObject rpc = new SoapObject 
("urn:xmethods-delayed-quotes", "getQuote");
// The addProperty method allows you to specify parameters to for 
// the method used.
rpc.addProperty ("symbol", symbol);
// The HttpTransport class can be used to make the actual call. 
// Its constructor accepts the Web Service endpoint as well as 
// the method to be called.
resultItem.setText (""+new HttpTransport 
("http://services.xmethods.net/soap",
"urn:xmethods-delayed-quotes#getQuote").call (rpc));
}
catch (Exception e) {
e.printStackTrace ();
resultItem.setLabel ("Error:");
resultItem.setText (e.toString ());
}
}
public static void main (String [] argv) {
new StockQuoteDemo ().startApp ();
}
}