java.lang.ClassCastException:android中的org.ksoap2.serialization.SoapObject

use*_*222 0 java mysql android ksoap2 android-ksoap2

嗨,我开发了一个Android应用程序.

应用程序的目的是从mysql数据库中检索数据并在android设备中显示.

这是我的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();
    }
}}
Run Code Online (Sandbox Code Playgroud)

如果我必须运行应用程序意味着只显示空白屏幕.它花了太长时间将近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)
Run Code Online (Sandbox Code Playgroud)

请帮帮我.我可以解决这个错误.

Cod*_*ife 5

更改

SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
Run Code Online (Sandbox Code Playgroud)

SoapObject response = (SoapObject)envelope.getResponse();
Run Code Online (Sandbox Code Playgroud)