title: java.lang.ClassCastException: org.ksoap2.serialization.SoapPrimitive cannot be cast to org.ksoap2.serialization.SoapObject
body: <p>I am doing soap parsing in android .These are the following steps I take while doing parsing
  1) I am download <strong>ksoap2-android-assembly-2.4-jar-with-dependencies (1).jar</strong> .
  2) Then I used this in this code But I am getting this error . </p>
  
  <pre><code>**java.lang.ClassCastException: org.ksoap2.serialization.SoapPrimitive cannot be cast to org.ksoap2.serialization.SoapObject**
  </code></pre>
  
  <p>Here is my code.</p>
  
  <pre><code> package com.example.networkconnectivity;
  
  import org.ksoap2.SoapEnvelope;
  import org.ksoap2.serialization.SoapObject;
  import org.ksoap2.serialization.SoapPrimitive;
  import org.ksoap2.serialization.SoapSerializationEnvelope;
  import org.ksoap2.transport.AndroidHttpTransport;
  
  import android.app.Activity;
  import android.app.ProgressDialog;
  import android.content.Context;
  import android.net.ConnectivityManager;
  import android.net.NetworkInfo;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.util.Log;
  import android.widget.Toast;
  
  public class MainActivity extends Activity {
      private static final String SOAP_ACTION = "http://wsendpoints.bbrailapps.firstgroup.com/getVersion";
      private static final String METHOD_NAME = "getVersion";
      private static final String NAMESPACE = "http://wsendpoints.bbrailapps.firstgroup.com";
      private static final String URL = "http://railapps.firstgroup.com/FirstGroupRailApps/services/RailAppsCAWS?wsdl";
      private SoapObject resultRequestSOAP = null;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          System.out.println("=====================" + haveNetworkConnection());
  
          new AsyncTask&lt;Void, Void, String&gt;() {
              ProgressDialog dialog = new ProgressDialog(MainActivity.this);
  
              protected void onPreExecute() {
                  dialog.show();
              };
  
              protected String doInBackground(Void[] params) {
  
                  resultRequestSOAP = new SoapObject(NAMESPACE, METHOD_NAME);
  
                  SoapSerializationEnvelope envp = new SoapSerializationEnvelope(
                          SoapEnvelope.VER11);
                  envp.dotNet = true;
                  envp.setOutputSoapObject(resultRequestSOAP);
                  AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(
                          URL);
                  try {
                      androidHttpTransport.call(SOAP_ACTION, envp);
                      SoapPrimitive resultsString = (SoapPrimitive)envp.getResponse();
                      return resultRequestSOAP.toString();    
  
                  } catch (Exception e) {
                      Log.i("WS Error-&gt;", e.toString());
                      return e.toString();
                  }
  
  
              };
  
              protected void onPostExecute(String result) {
                  dialog.dismiss();
                  Toast.makeText(MainActivity.this,
                          "Check Network connectivety" + result,
                          Toast.LENGTH_LONG).show();
              };
          }.execute();
  
      }
  
      public boolean haveNetworkConnection() {
          boolean haveConnectedWifi = false;
          boolean haveConnectedMobile = false;
  
          ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
          NetworkInfo[] netInfo = cm.getAllNetworkInfo();
          for (NetworkInfo ni : netInfo) {
              if (ni.getTypeName().equalsIgnoreCase("WIFI"))
                  if (ni.isConnected())
                      haveConnectedWifi = true;
              if (ni.getTypeName().equalsIgnoreCase("MOBILE"))
                  if (ni.isConnected())
                      haveConnectedMobile = true;
          }
          return haveConnectedWifi || haveConnectedMobile;
      }
  
  }
  </code></pre>