aspose file tools*
The moose likes Java Micro Edition and the fly likes Problem in connecting web service from j2me Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Problem in connecting web service from j2me" Watch "Problem in connecting web service from j2me" New topic
Author

Problem in connecting web service from j2me

majety srikanth
Greenhorn

Joined: Jan 25, 2011
Posts: 14
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:\Users\srikanthnagachandm\j2mewtk\2.5.2\appdb\DefaultColorPhone
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)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem in connecting web service from j2me