[英]Not able to access web-service in Android
Not been able to access the webservice with a kinds of Android. 无法使用多种Android访问Web服务。 I am using Eclipse and ksoap2 library. 我正在使用Eclipse和ksoap2库。 I've tried all the codes circulating on the Internet. 我已经尝试了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:51.872:E / Trace(972):打开跟踪文件时出错:没有这样的文件或目录(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.143:E / dalvikvm(972):找不到方法com.knnklz.webservice04.MainActivity $ 2.run引用的类'org.ksoap2.serialization.SoapObject'
08-25 11:32:56.193: E/AndroidRuntime(972): FATAL EXCEPTION: Thread-93 08-25 11:32:56.193:E / AndroidRuntime(972):致命异常: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):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) 08-25 11:32:56.193:E / AndroidRuntime(972):在com.knnklz.webservice04.MainActivity $ 2.run(MainActivity.java:277)
Android Java Code Android Java代码
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. 在项目目录中创建一个名为“ libs ”的文件夹,并将所有外部jar文件复制到该目录中。
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 " 通过右键单击jar文件,然后单击“ 添加以构建 ”,确保已将ksoap库添加到构建路径。
Plus make sure you are using the latest version of the ksoap library. 另外,请确保您使用的是ksoap库的最新版本。 Direct download link . 直接下载链接 。
I removed the following line, and improved. 我删除了以下行,并进行了改进。
File: AndroidManifest.xml 档案: AndroidManifest.xml
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.