Android SOAP Sample program error
How to rectify this error. please help me
Main.java
public class Main extends Activity {
private static String SOAP_ACTION = "http://tempuri.org/HelloWorld";
private static String NAMESPACE = "http://tempuri.org/";
private static String METHOD_NAME = "HelloWorld";
private static String URL = "http://sygnetinfosol.com/webservice.asmx";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Initialize soap request + add parameters
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("Parameter","Value");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
// Make the soap call.
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
//this is the actual part that will call the webservice
androidHttpTransport.call(SOAP_ACTION, envelope);
} catch (Exception e) {
e.printStackTrace();
}
// Get the SoapResult from the envelope body.
SoapObject result = (SoapObject)envelope.bodyIn;
if(result != null){
TextView t = (TextView)this.findViewById(R.id.resultbox);
t.setText("SOAP response:\n\n" + result.getProperty(0).toString());
}
}
}
Logcat Error
03-11 07:07:07.320: E/AndroidRuntime(908): FATAL EXCEPTION: main
03-11 07:07:07.320: E/AndroidRuntime(908): java.lang.NoClassDefFoundError: org.ksoap2.serialization.SoapObject
03-11 07:07:07.320: E/AndroidRuntime(908): at com.pxr.tutorial.soap.weather.Main.onCreate(Main.java:29)
03-11 07:07:07.320: E/AndroidRuntime(908): at android.app.Activity.performCreate(Activity.java:5104)
03-11 07:07:07.320: E/AndroidRuntime(908): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
03-11 07:07:07.320: E/AndroidRuntime(908): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
03-11 07:07:07.320: E/AndroidRuntime(908): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-11 07:07:07.320: E/AndroidRuntime(908): at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-11 07:07:07.320: E/AndroidRuntime(908): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-11 07:07:07.320: E/AndroidRuntime(908): at android.os.Handler.dispatchMessage(Handler.java:99)
03-11 07:07:07.320: E/AndroidRuntime(908): at android.os.Looper.loop(Looper.java:137)
03-11 07:07:07.320: E/AndroidRuntime(908): at android.app.ActivityThread.main(ActivityThread.java:5041)
03-11 07:07:07.320: E/AndroidRuntime(908): at java.lang.reflect.Method.invokeNative(Native Method)
03-11 07:07:07.320: E/AndroidRuntime(908): at java.lang.reflect.Method.invoke(Method.java:511)
03-11 07:07:07.320: E/AndroidRuntime(908): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-11 07:07:07.320: E/AndroidRuntime(908): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-11 07:07:07.320: E/AndroidRuntime(908): at dalvik.system.NativeStart.main(Native Method)
ksoap2-android-assembly-2.6.2-jar-with-dependencies.jar
to be put under /libs folder so Eclipse ADT automatically adds your jars to the buildpath of your application.
Download ksoap. jar. Put it under libs folder. Right click on project. Goto properties. Goto java build path. CLick add jars. Add the ksaop jar file to your project from the lib folder.
Clean and build the project. This should help you.
Edit1
Right click "project" -> Properties -> Java Build Path -> Order And Export

Now, make sure that, you have "Checked" that external added "jar" file as you can see in the snap. Make sure that order of that external jar file also same like displayed in snap.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With