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

Please Login to Remove!

Hi,

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 org.ksoap2.transport.HttpTransport.call(Unknown Source)
at FirstClass.GetResult(FirstClass.java:50)
at FirstClass.main(FirstClass.java:22)
Caused by: java.lang.ClassNotFoundException: javax.microedition.io.Connector
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown 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;
envelope.setOutputSoapObject(soap);

/*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;

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

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

return result;
}
Offline   Reply With Quote