F
Fra
Hi everyone! Sorry for my poor english... My name is Francesco, from Italy.
I'm writing a Midled using kSoap for parsing SOAP request/response. With
J2ME Wireless Toolkit I tested my application succesfully, but I have a
problem testing on my sony-ericsson k700. This is a very simple test Midlet
that parse a static SOAP document using kSoap:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
import org.ksoap.*;
import org.kxml.parser.*;
public class TestMidlet extends MIDlet implements CommandListener, Runnable
{
Form mainForm = new Form ("TestMidlet");
Command testCommand = new Command ("Test", Command.SCREEN, 1);
Command exitCommand = new Command ("Exit", Command.EXIT, 1);
public TestMidlet () {
mainForm.addCommand (testCommand);
mainForm.addCommand(exitCommand);
mainForm.setCommandListener (this);
}
public void startApp () {
Display.getDisplay (this).setCurrent (mainForm);
}
public void pauseApp () {
notifyPaused();
}
public void destroyApp (boolean unconditional) {
notifyDestroyed();
}
public void commandAction (Command c, Displayable d) {
if(c == this.testCommand){
new Thread(this).start();
}
else if(c == exitCommand){
destroyApp(true);
}
}
public void run(){
try{
String soap="<?xml version=\"1.0\"
encoding=\"UTF-8\"?><soapenv:Envelope
xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soapenv:Body><ns1:g
etNumeroPuntiDiVenditaResponse
soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"
xmlns:ns1=\"http://DefaultNamespace\"><getNumeroPuntiDiVenditaReturn
xsi:type=\"xsd:int\">35</getNumeroPuntiDiVenditaReturn></ns1:getNumeroPuntiD
iVenditaResponse></soapenv:Body></soapenv:Envelope>";
InputStreamReader isr=new InputStreamReader(new
ByteArrayInputStream(soap.getBytes()));
XmlParser xmlparser = new XmlParser(isr);
SoapEnvelope responseEnvelope=new SoapEnvelope();
this.mainForm.append("Start parsing\n");
responseEnvelope.parse(xmlparser);
this.mainForm.append("End parsing\n");
}
catch(Exception e){
mainForm.append(e.toString ());
}
}
}
When I install application on my phone, only the first time it work fine...
all the others times I try to exit and run again Midlet an exception is
thrown. The exception is:
org.kxml.parser.XmlParser$DefaultParserException:
java.lang.RuntimeException: Method not supported for the given event type!
@1:214
If I remove Midlet and then reinstall it the behavior is the same... only
first run is ok! It's not possible... My opinion is that the JVM on my phone
have a bug.
Please, can anyone install this simple Midlet on his phone to test if the
problem is my k700, my source or kSoap libraries? All that we need is
kSoap+Kxml library, downloadable at
http://ksoap.objectweb.org/software/downloads/current/ksoap-midp.zip
In J2ME Wireless Toolkit just create a new project named "TestMidlet", whit
MIdlet name "TestMidled", put ksoap-midp.zip in lib directory of the
project, put the source of Midlet (TestMidlet.java) in src directory of the
project and choose "Project->Package->Create Package". Now "TestMidlet.jad"
and "TestMidlet.jar" are in bin directory of project. Install Midlet to
phone and test... exit Midlet and re-test... exit and re-test...
If you want to help me (or for more information), please reply to this topic
or contact me at (e-mail address removed).
Thanks to all! Francesco.
I'm writing a Midled using kSoap for parsing SOAP request/response. With
J2ME Wireless Toolkit I tested my application succesfully, but I have a
problem testing on my sony-ericsson k700. This is a very simple test Midlet
that parse a static SOAP document using kSoap:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
import org.ksoap.*;
import org.kxml.parser.*;
public class TestMidlet extends MIDlet implements CommandListener, Runnable
{
Form mainForm = new Form ("TestMidlet");
Command testCommand = new Command ("Test", Command.SCREEN, 1);
Command exitCommand = new Command ("Exit", Command.EXIT, 1);
public TestMidlet () {
mainForm.addCommand (testCommand);
mainForm.addCommand(exitCommand);
mainForm.setCommandListener (this);
}
public void startApp () {
Display.getDisplay (this).setCurrent (mainForm);
}
public void pauseApp () {
notifyPaused();
}
public void destroyApp (boolean unconditional) {
notifyDestroyed();
}
public void commandAction (Command c, Displayable d) {
if(c == this.testCommand){
new Thread(this).start();
}
else if(c == exitCommand){
destroyApp(true);
}
}
public void run(){
try{
String soap="<?xml version=\"1.0\"
encoding=\"UTF-8\"?><soapenv:Envelope
xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soapenv:Body><ns1:g
etNumeroPuntiDiVenditaResponse
soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"
xmlns:ns1=\"http://DefaultNamespace\"><getNumeroPuntiDiVenditaReturn
xsi:type=\"xsd:int\">35</getNumeroPuntiDiVenditaReturn></ns1:getNumeroPuntiD
iVenditaResponse></soapenv:Body></soapenv:Envelope>";
InputStreamReader isr=new InputStreamReader(new
ByteArrayInputStream(soap.getBytes()));
XmlParser xmlparser = new XmlParser(isr);
SoapEnvelope responseEnvelope=new SoapEnvelope();
this.mainForm.append("Start parsing\n");
responseEnvelope.parse(xmlparser);
this.mainForm.append("End parsing\n");
}
catch(Exception e){
mainForm.append(e.toString ());
}
}
}
When I install application on my phone, only the first time it work fine...
all the others times I try to exit and run again Midlet an exception is
thrown. The exception is:
org.kxml.parser.XmlParser$DefaultParserException:
java.lang.RuntimeException: Method not supported for the given event type!
@1:214
If I remove Midlet and then reinstall it the behavior is the same... only
first run is ok! It's not possible... My opinion is that the JVM on my phone
have a bug.
Please, can anyone install this simple Midlet on his phone to test if the
problem is my k700, my source or kSoap libraries? All that we need is
kSoap+Kxml library, downloadable at
http://ksoap.objectweb.org/software/downloads/current/ksoap-midp.zip
In J2ME Wireless Toolkit just create a new project named "TestMidlet", whit
MIdlet name "TestMidled", put ksoap-midp.zip in lib directory of the
project, put the source of Midlet (TestMidlet.java) in src directory of the
project and choose "Project->Package->Create Package". Now "TestMidlet.jad"
and "TestMidlet.jar" are in bin directory of project. Install Midlet to
phone and test... exit Midlet and re-test... exit and re-test...
If you want to help me (or for more information), please reply to this topic
or contact me at (e-mail address removed).
Thanks to all! Francesco.