无法使用某种 Android 访问 Web 服务。我正在使用 Eclipse 和 ksoap2 库。网上流传的所有代码我都试过了。我正在做的错误在哪里。我再次安装了所有东西,但没有帮助。
错误日志
08-25 11:32:51.872: E/Trace(972): 打开跟踪文件时出错: 没有这样的文件或目录 (2)
08-25 11:32:56.143: E/dalvikvm(972): 找不到类 'org.ksoap2.serialization.SoapObject',引用自方法 com.knnklz.webservice04.MainActivity$2.run
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): at com.knnklz.webservice04.MainActivity$2.run(MainActivity.java:277)
安卓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();
}