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!