Not been able to access the webservice with a kinds of Android. I am using Eclipse and ksoap2 library. I've tried all the codes circulating on the Internet. Where is the error I'm doing. I installed everything again, but it did not help.
Error Logs
08-25 11:32:51.872: E/Trace(972): error opening trace file: No such file or directory (2)
08-25 11:32:56.143: E/dalvikvm(972): Could not find class 'org.ksoap2.serialization.SoapObject', referenced from method com.knnklz.webservice04.MainActivity$2.run
08-25 11:32:56.193: E/AndroidRuntime(972): FATAL EXCEPTION: Thread-93
08-25 11:32:56.193: E/AndroidRuntime(972): java.lang.NoClassDefFoundError: org.ksoap2.serialization.SoapObject
08-25 11:32:56.193: E/AndroidRuntime(972): at com.knnklz.webservice04.MainActivity$2.run(MainActivity.java:277)
Android Java Code
tx = (TextView)findViewById(R.id.textView1);
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("Celsius", "85");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
tx.setText(response.toString());
} catch (Exception e1) {
e1.printStackTrace();
}
There are only three reasons you will ever get this error:
Create a folder named " libs " in the project directory and copying all the external jar files there.
Make sure you have added the ksoap library to the Build Path by by right clicking on the jar file and " Add it to build "
Plus make sure you are using the latest version of the ksoap library. Direct download link .
I removed the following line, and improved.
File: AndroidManifest.xml
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.