0
I have a C# Web Service but I can’t consume it on Android
. Follows the Code of android
and the LogCat
.
//----------------------------- Conectando a Base WS
class asynProjeto extends AsyncTask<String,String,String>{
@Override
protected void onPreExecute(){
super.onPreExecute();
Log.i("AsyncTask", "onPreExecute");
dialogo = new ProgressDialog(MainActivity.this);
dialogo.setMessage("Carregando");
dialogo.setIndeterminate(false);
dialogo.setCancelable(false);
dialogo.show();
}
@Override
protected void onPostExecute(String s){
//super.onPostExecute(s);
dialogo.dismiss();
if(s.equals("ok")){
carregarHello();
}else {
Log.e("Script", "Deu Errado:" + s);
}
}
@Override
protected String doInBackground(String... strings){
if (Hello()){
return "Ok";
}else{
return "erro";
}
}
And that’s the exception:
02-03 14:34:54.604 3372-3398/com.example.cpires.myapplication E/Androidruntime: FATAL EXCEPTION: Asynctask #1
Process: com.example.cpires.myapplication, PID: 3372 java.lang.Runtimeexception: An error occurred while executing doInBackground()
Caused by: java.lang.Noclassdeffounderror: Failed Resolution of: Ljavax/microedition/io/Connector; at org.ksoap2.transport.Serviceconnectionmidp.(Unknown Source) at org.ksoap2.transport.Httptransport.getServiceConnection(Unknown Source) at org.ksoap2.transport.Httptransport.call(Unknown Source) at com.example.cpires.myapplication.Mainactivity.Hello(Mainactivity.java:129) at com.example.cpires.myapplication.Mainactivity$asynProjeto.doInBackground(Mainactivity.java:94) at com.example.cpires.myapplication.Mainactivity$asynProjeto.doInBackground(Mainactivity.java:76) at android.os.Asynctask$2.call(Asynctask.java:295) at java.util.Concurrent.FutureTask.run(Futuretask.java:237) at android.os.Asynctask$Serialexecutor$1.run(Asynctask.java:234) at java.util.Concurrent.ThreadPoolExecutor.runWorker(Threadpoolexecutor.java:1113) at java.util.Concurrent.Threadpoolexecutor$Worker.run(Threadpoolexecutor.java:588) at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.Classnotfoundexception: Didn’t find class "javax.microedition.io.Connector" on path: Dexpathlist[[zip file "/data/app/com.example.cpires.myapplication-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.cpires.myapplication-2/lib/x86, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.Classloader.loadClass(Classloader.java:511) at java.lang.Classloader.loadClass(Classloader.java:469) at org.ksoap2.transport.Serviceconnectionmidp.(Unknown Source) at org.ksoap2.transport.Httptransport.getServiceConnection(Unknown Source) at org.ksoap2.transport.Httptransport.call(Unknown Source) at com.example.cpires.myapplication.Mainactivity.Hello(Mainactivity.java:129) at com.example.cpires.myapplication.Mainactivity$asynProjeto.doInBackground(Mainactivity.java:94) at com.example.cpires.myapplication.Mainactivity$asynProjeto.doInBackground(Mainactivity.java:76) at android.os.Asynctask$2.call(Asynctask.java:295) at java.util.Concurrent.FutureTask.run(Futuretask.java:237) at android.os.Asynctask$Serialexecutor$1.run(Asynctask.java:234) at java.util.Concurrent.ThreadPoolExecutor.runWorker(Threadpoolexecutor.java:1113) at java.util.Concurrent.Threadpoolexecutor$Worker.run(Threadpoolexecutor.java:588) at java.lang.Thread.run(Thread.java:818) Suppressed: java.lang.Classnotfoundexception: javax.microedition.io.Connector at java.lang.Class.classForName(Native Method) at java.lang.Bootclassloader.findClass(Classloader.java:781) at java.lang.Bootclassloader.loadClass(Classloader.java:841) at java.lang.Classloader.loadClass(Classloader.java:504) ... 13 more Caused by: java.lang.Noclassdeffounderror: Class not found using the boot class Loader; no stack trace available
Dude, try directing to the part of code you think is the problem...
– Felipe Avelar
The URL you are using (
http://localhost:2749/Service.asmx?WSDL
) is the address of description web service (WSDL), not the service itself (which should be the same URL, without the?WSDL
).– carlosfigueira
I do not understand the negativity in the question of the guy... ta missing a little quality and perception on the part of those who want to answer... take a look at my answer and see if it helped!
– Danilo Breda