Thread: J2ME error??
View Single Post
Old 09-02-2008, 04:55 AM   #1 (permalink)
Knows Where the Search Button Is
Join Date: Aug 2008
Location: Scotland
Model: None!
Carrier: Vodafone
Posts: 31
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default J2ME error??

Please Login to Remove!


I'm a .NET developer by trade so still getting my head round this Java stuff.

I'm calling a WebService using KSoap2. I got a demo working just using standard Java app using the ksoap2-j2se-full-2.1.2.jar. I could not get this jar file to verify so i tried using the ksoap2-j2me-core-2.1.2.jar as I verify this.

Now when I add it to the project I get the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/microedition/io/Connector
at org.ksoap2.transport.ServiceConnectionMidp.<init>( Unknown Source)
at org.ksoap2.transport.HttpTransport.getServiceConne ction(Unknown Source)
at Source)
at FirstClass.GetResult(
at FirstClass.main(
Caused by: java.lang.ClassNotFoundException:
at$ Source)
at Method)
at Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 5 more

Is this to do with me not using J2ME??? If so is this part of the J2SE? Or am I missing something more obvious?

My code is as follows: (i've added ** as i can't post links)

public static String GetResult()
String result = "";

SoapObject soap = new SoapObject("**localhost/BBWebservice", "HelloWorld");

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;

/*With J2SE version would use the following line which worked
*HttpTransportSE ht = new HttpTransportSE("**localhost/BBWebservice/service.asmx"); */
HttpTransport ht = new HttpTransport("**localhost/BBWebservice/service.asmx");
ht.debug = true;

System.out.println("CALLING WEBSERVICE");"**localhost/BBWebservice/HelloWorld", envelope);

System.out.println("GETTING RESPONSE");
result = (envelope.getResponse()).toString();
catch(Exception ex){
System.out.println("ERROR: "+ ex.toString());

return result;
Offline   Reply With Quote