0

I've browsed a lot of article regarding consuming .net web service with android but it seems that I can't make it work.

  • I've donwloaded "ksoap2-android-assembly-2.6.2-jar-with-dependencies" and add it in as an external jar in my current project.

  • I've already put uses-permission android:name="android.permission.INTERNET" in the manifest file.

When I debug the program and call the function, the application say's "The application * (*) has stopped unexpectedly. Please try again."

What am I doing wrong? Here's my code:

private static final String NAMESPACE = "http://epson.com.ph/";
private static final String SOAP_ACTION = "http://epson.com.ph/TheMessage";
private static final String METHOD_NAME = "TheMessage";
private static final String URL = "http://10.0.2.2/DataAccess.asmx";

private void getData(){ 
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

    //request.addProperty("selectStatement", "SELECT * FROM ALLDETAILS");

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

    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 
    TextView tv = (TextView)findViewById(R.id.txtPreview); 

    try { 
        androidHttpTransport.call(SOAP_ACTION, envelope); 
        Object result = (Object)envelope.getResponse();

        tv.setText(result.toString()); 
    } catch (Exception ex) { 
        messageBox(ex.getMessage()); 
        } 
} 

The logcat errors are:

04-10 11:04:46.156: E/AndroidRuntime(332): FATAL EXCEPTION: main
04-10 11:04:46.156: E/AndroidRuntime(332): java.lang.NoClassDefFoundError: org.ksoap2.serialization.SoapObject
04-10 11:04:46.156: E/AndroidRuntime(332):  at my.WSCA.WebServiceConsumptionActivity.getData(WebServiceConsumptionActivity.java:53)
04-10 11:04:46.156: E/AndroidRuntime(332):  at my.WSCA.WebServiceConsumptionActivity.access$0(WebServiceConsumptionActivity.java:52)
04-10 11:04:46.156: E/AndroidRuntime(332):  at my.WSCA.WebServiceConsumptionActivity$1.onClick(WebServiceConsumptionActivity.java:42)
04-10 11:04:46.156: E/AndroidRuntime(332):  at android.view.View.performClick(View.java:2485)
04-10 11:04:46.156: E/AndroidRuntime(332):  at android.view.View$PerformClick.run(View.java:9080)
04-10 11:04:46.156: E/AndroidRuntime(332):  at android.os.Handler.handleCallback(Handler.java:587)
04-10 11:04:46.156: E/AndroidRuntime(332):  at android.os.Handler.dispatchMessage(Handler.java:92)
04-10 11:04:46.156: E/AndroidRuntime(332):  at android.os.Looper.loop(Looper.java:123)
04-10 11:04:46.156: E/AndroidRuntime(332):  at android.app.ActivityThread.main(ActivityThread.java:3683)
04-10 11:04:46.156: E/AndroidRuntime(332):  at java.lang.reflect.Method.invokeNative(Native Method)
04-10 11:04:46.156: E/AndroidRuntime(332):  at java.lang.reflect.Method.invoke(Method.java:507)
04-10 11:04:46.156: E/AndroidRuntime(332):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-10 11:04:46.156: E/AndroidRuntime(332):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-10 11:04:46.156: E/AndroidRuntime(332):  at dalvik.system.NativeStart.main(Native Method)

Please help me, I needed to make this work as soon as possible. Thanks!

Cody
  • 8,061
  • 17
  • 65
  • 120
  • may be the same case http://stackoverflow.com/questions/10005206/twitter4j-androidruntime446-java-lang-noclassdeffounderror-twitter4j-http/10007966#10007966 – MKJParekh Apr 10 '12 at 05:15
  • This can be your environment set up problem.However, there is a similar solution in this site http://stackoverflow.com/questions/9853113/android-ksoap2-java-lang-noclassdeffounderror-org-ksoap2-serialization-soapobje – UVM Apr 10 '12 at 04:55

1 Answers1

0

Thank you for all your reply, I already got a solution. Just like what Frankenstein says, its slightly the same case on the link that he gave.

I've put a libs folder on the project and import the ksoap jar. I'm just wondering, why is libs folder not automatically included in every project, will the solution work if I had named it with a different folder name.