嗨,我开发了一个 android 应用程序。
该应用程序的目的是从 mysql 数据库中检索数据并显示在 android 设备中。
这是我的安卓代码:
public class RetailerActivity extends Activity {
private final String NAMESPACE = "http://ws.testprops.com";
private final String URL = "http://krish.jelastic.servint.net/Retrieve/services/Fetch?wsdl";
private final String SOAP_ACTION = "http://ws.testprops.com/customerData";
private final String METHOD_NAME = "customerData";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE ht = new HttpTransportSE(URL);
try {
ht.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
SoapPrimitive s = response;
String str = s.toString();
String resultArr[] = str.split("&");//Result string will split & store in an array
TextView tv = new TextView(this);
for(int i = 0; i<resultArr.length;i++){
tv.append(resultArr[i]+"\n\n");
}
setContentView(tv);
} catch (Exception e) {
e.printStackTrace();
}
}}
如果我必须运行该应用程序意味着只显示空白屏幕。它花费了近 1 小时的时间太长,我的 android 控制台窗口上也出现以下错误:
11-05 10:38:27.868: W/System.err(837): java.lang.ClassCastException: org.ksoap2.serialization.SoapObject
11-05 10:38:27.878: W/System.err(837): at com.retailer.client.RetailerActivity.onCreate(RetailerActivity.java:29)
11-05 10:38:27.878: W/System.err(837): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-05 10:38:27.878: W/System.err(837): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
11-05 10:38:27.878: W/System.err(837): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-05 10:38:27.878: W/System.err(837): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-05 10:38:27.878: W/System.err(837): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-05 10:38:27.878: W/System.err(837): at android.os.Handler.dispatchMessage(Handler.java:99)
11-05 10:38:27.878: W/System.err(837): at android.os.Looper.loop(Looper.java:123)
11-05 10:38:27.878: W/System.err(837): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-05 10:38:27.878: W/System.err(837): at java.lang.reflect.Method.invokeNative(Native Method)
11-05 10:38:27.878: W/System.err(837): at java.lang.reflect.Method.invoke(Method.java:521)
11-05 10:38:27.878: W/System.err(837): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-05 10:38:27.878: W/System.err(837): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-05 10:38:27.888: W/System.err(837): at dalvik.system.NativeStart.main(Native Method)
请帮助我。我该如何解决这个错误。