rendered paste body
package client;
import java.io.IOException;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransport;
import org.ksoap2.serialization.PropertyInfo;
import org.xmlpull.v1.XmlPullParserException;
public class SimpleClient
extends MIDlet
implements Runnable {
private Display display;
private String url = "http://localhost:8080/axis/Service";
TextBox textbox = null;
public void startApp() {
Thread t = new Thread(this);
t.start();
}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
public void testWebService()
throws IOException {
StringBuffer stringBuffer = new StringBuffer();
TextBox textBox = null;
String method = "sum";
// Call the WebService
SoapObject client = new SoapObject(url,method);
HttpTransport transport = new HttpTransport(url);
client.addProperty("value1",new Integer(2));
client.addProperty("value2",new Integer(4));
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = client;
envelope.addMapping("http://xml.apache.org/xml-soap","Integer",PropertyInfo.INTEGER_CLASS);
try{
transport.call(method, envelope);
}catch(XmlPullParserException io) {
System.err.println(io);
}
String result = envelope.getResponse().toString();
stringBuffer.append("Resultado: " + result);
// show the value on the screen.
textBox = new TextBox("Test WebService", stringBuffer.toString(), 1024, 0);
display.setCurrent(textBox);
}
public void run() {
display = Display.getDisplay(this);
try {
testWebService();
} catch (IOException ex) {
System.out.println(ex);
}
}
}
Error: Uncaught exception java/lang/RuntimeException: Cannot serialize: 2.