Problem in connecting web service using J2ME
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   majety_srikanth
Posted On:   Tuesday, January 25, 2011 06:40 AM

Hi, I am a newbie to J2ME. I did not get any step by step guidelines to connect to a web service using j2me. After searching a lot, Based on some example, I tried to connect a webservice using j2me midlet. It is giving "java.lang.NoClassDefFoundError: org/ksoap/SoapObject" error, even though I have included ksoap-j2se.jar also in buildpath(download from http://ksoap.objectweb.org/software/downloads/) please help me. Thanks for your help in advance. ############################################################## here is the program ############################################################## import javax.microedition.midlet.*; import javax.microedition.lcdui.*; impor   More>>

Hi,
I am a newbie to J2ME. I did not get any step by step guidelines to connect to a web service using j2me. After searching a lot, Based on some example, I tried to connect a webservice using j2me midlet.

It is giving "java.lang.NoClassDefFoundError: org/ksoap/SoapObject" error, even though I have included ksoap-j2se.jar also in buildpath(download from http://ksoap.objectweb.org/software/downloads/)

please help me. Thanks for your help in advance.

##############################################################
here is the program
##############################################################
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
import javax.microedition.io.*;

import org.ksoap.*;
import org.ksoap.transport.*;
import org.ksoap.SoapObject;

public class testWebService extends MIDlet {

private Display display;
private String url = "http://172.16.25.149/FPSTCService/STC.asmx";
TextBox textBox = null;
private Command cmExit;

public testWebService()
{
display = Display.getDisplay(this);

}

public void startApp() {
try
{
doWebService(url);
}
catch(Exception e)
{
System.out.println("Exception: " + e);
}

}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
destroyApp(false);
notifyDestroyed();
}


public void doWebService(String url) throws Exception
{
StringBuffer sb = new StringBuffer();
TextBox textBox = null;

SoapObject client = new SoapObject("http://tempuri.org/", "checkLogin");
client.addProperty("Username","sgonsite");
client.addProperty("Password","Test123");
client.addProperty("DeviceId", "2237951d");



HttpTransportSE ht = new HttpTransportSE(url, "checkLogin");
sb.append("" + ht.call(client));
System.out.println("here is output ----- " + client.getNamespace());


textBox = new TextBox("Simple Web Service Test: ", sb.toString(), 1024, 0);
display.setCurrent(textBox);
}

}
##############################################################

Here is the error
##############################################################

Running with storage root C:Userssrikanthnagachandmj2mewtk2.5.2appdbDefaultColorPhone
Running with locale: English_United States.1252
Running in the identified_third_party security domain
java.lang.NoClassDefFoundError: org/ksoap/SoapObject
at testWebService.doWebService(+10)
at testWebService.startApp(+8)
at javax.microedition.midlet.MIDletProxy.startApp(+7)
at com.sun.midp.midlet.Scheduler.schedule(+270)
at com.sun.midp.main.Main.runLocalClass(+28)
at com.sun.midp.main.Main.main(+80)
Execution completed.
3407637 bytecodes executed
26 thread switches
1669 classes in the system (including system classes)
17711 dynamic objects allocated (532164 bytes)
3 garbage collections (459628 bytes collected)

   <<Less
About | Sitemap | Contact