title: Android Ksoap Passing Object as Parameter Error
body: <p>I am communicating with a web-service by sending an Object along with the request.</p>
  
  <p>This is the format of the request to the web-service.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  &lt;soap:Body&gt;
  &lt;UpdateLocation xmlns="http://tempuri.org/"&gt;
  &lt;location&gt;
  &lt;Id&gt;int&lt;/Id&gt;
  &lt;TabletId&gt;int&lt;/TabletId&gt;
  &lt;SpeedVisibility&gt;boolean&lt;/SpeedVisibility&gt;
  &lt;BeltVisibility&gt;boolean&lt;/BeltVisibility&gt;
  &lt;LightVisibility&gt;boolean&lt;/LightVisibility&gt;
  &lt;ProjectorVisibility&gt;boolean&lt;/ProjectorVisibility&gt;
  &lt;DefStart&gt;int&lt;/DefStart&gt;
  &lt;DefEnd&gt;int&lt;/DefEnd&gt;
  &lt;DefPickerCount&gt;int&lt;/DefPickerCount&gt;
  &lt;DefSlotCount&gt;int&lt;/DefSlotCount&gt;
  &lt;ServerIP&gt;string&lt;/ServerIP&gt;
  &lt;WebURL&gt;string&lt;/WebURL&gt;
  &lt;/location&gt;
  &lt;/UpdateLocation&gt;
  &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>This is my java code to make the request.</p>
  
  <pre><code>private void updateSettingsOnServer() {
  SoapObject request = new SoapObject(NAMESPACE, METHOD_UPDATE_SETTINGS);
  
  Location serverObject = new Location(currentLocation.databaseId, currentLocation.tabletId, currentLocation.isSpeedVisible, currentLocation.isBeltVisible, currentLocation.isLightVisible, currentLocation.isProjectorVisible, currentLocation.slotStarting, currentLocation.slotEnding, prefPickerCount, prefSlotCount, prefServerIPString, prefWebURL);
  
  
   PropertyInfo pi = new PropertyInfo();
      pi.setName("serverObject");
      pi.setValue(serverObject);
      pi.setType(serverObject.getClass());
      request.addProperty(pi);
  
  
  
  
  SoapSerializationEnvelope envelope = 
      new SoapSerializationEnvelope(SoapEnvelope.VER11); 
  envelope.dotNet = true;
  envelope.setOutputSoapObject(request);
  
  
  
  envelope.addMapping(NAMESPACE,"Location",new Location().getClass());
  
  
  HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
  
  
  
  
  try {
      androidHttpTransport.call(SOAP_ACTION_UPDATE_SETTINGS, envelope);
  
  
  
  
      SoapObject result=(SoapObject)envelope.getResponse(); //To get the data.
      tempText.setText("Received :" + result.toString());
  
  }
  catch(Exception e)
  {
  
      tempText.setText("Error");
      //Toast.makeText(context, "Error", Toast.LENGTH_LONG).show();
      e.printStackTrace();
  }
  
  }
  </code></pre>
  
  <p>I made my custom class KVMSerializable in the following manner.</p>
  
  <pre><code>class Location implements KvmSerializable
  {
  public Location(int id, int tabletid, boolean speed, boolean belt, boolean light, boolean projector, int start, int end, int picker, int slot, String server, String web)
  {
      databaseId =id;
      tabletId = tabletid;
      isSpeedVisible = speed;
      isBeltVisible = belt;
      isLightVisible = light;
      isProjectorVisible = projector;
      slotStarting = start;
      slotEnding = end;
      pickerCounting = picker;
      slotCounting = slot;
      serverUrlLink = server;
      webUrlLink = web;
  
  
  }
  
  public Location() {
      // TODO Auto-generated constructor stub
  }
  
  boolean isSpeedVisible, isLightVisible, isBeltVisible, isProjectorVisible;
  int slotStarting, slotEnding , pickerCounting, slotCounting;
  int databaseId, tabletId;
  String serverUrlLink, webUrlLink;
  
  
  public Object getProperty(int arg0) {
      // TODO Auto-generated method stub
  
       switch(arg0)
          {
          case 0:
              return databaseId;
          case 1:
              return tabletId;
          case 2:
              return isSpeedVisible;
          case 3:
              return isBeltVisible;
          case 4:
              return isLightVisible;
          case 5:
              return isProjectorVisible;
          case 6:
              return slotStarting;
          case 7:
              return slotEnding;
          case 8:
              return pickerCounting;
          case 9:
              return slotCounting;
          case 11:
              return serverUrlLink;
          case 12:
              return webUrlLink;
  
          }
  
       return null;
  }
  
  
  public int getPropertyCount() {
      // TODO Auto-generated method stub
      return 12;
  }
  
  
  
  public void getPropertyInfo(int arg0, Hashtable arg1, PropertyInfo info) {
      // TODO Auto-generated method stub
  
      switch(arg0)
      {
      case 0:
          info.type = PropertyInfo.INTEGER_CLASS;
          info.name = "databaseId";
          break;
      case 1:
          info.type = PropertyInfo.INTEGER_CLASS;
          info.name = "tabletId";
          break;
      case 2:
          info.type = PropertyInfo.BOOLEAN_CLASS;
          info.name = "isSpeedVisible";
          break;
      case 3:
          info.type = PropertyInfo.BOOLEAN_CLASS;
          info.name = "isBeltVisible";
          break;
      case 4:
          info.type = PropertyInfo.BOOLEAN_CLASS;
          info.name = "isLightVisible";
          break;
      case 5:
          info.type = PropertyInfo.BOOLEAN_CLASS;
          info.name = "isProjectorVisible";
          break;
      case 6:
          info.type = PropertyInfo.INTEGER_CLASS;
          info.name = "slotStarting";
          break;
      case 7:
          info.type = PropertyInfo.STRING_CLASS;
          info.name = "slotEnding";
          break;
      case 8:
          info.type = PropertyInfo.STRING_CLASS;
          info.name = "pickerCounting";
          break;
      case 9:
          info.type = PropertyInfo.INTEGER_CLASS;
          info.name = "slotCounting";
          break;
      case 11:
          info.type = PropertyInfo.STRING_CLASS;
          info.name = "serverUrlLink";
          break;
      case 12:
          info.type = PropertyInfo.STRING_CLASS;
          info.name = "webUrlLink";
          break;
  
      default:break;
      }
  
  
  
  }
  public void setProperty(int index, Object value) {
      // TODO Auto-generated method stub
  
      switch(index)
      {
      case 0:
          databaseId = Integer.parseInt(value.toString());
          break;
      case 1:
          tabletId = Integer.parseInt(value.toString());
          break;
      case 2:
          isSpeedVisible = Boolean.parseBoolean(value.toString());
          break;
      case 3:
          isBeltVisible = Boolean.parseBoolean(value.toString());
          break;
      case 4:
          isLightVisible = Boolean.parseBoolean(value.toString());
          break;
      case 5:
          isProjectorVisible = Boolean.parseBoolean(value.toString());
          break;
      case 6:
          slotStarting = Integer.parseInt(value.toString());
          break;
      case 7:
          slotEnding = Integer.parseInt(value.toString());
          break;
      case 8:
          pickerCounting = Integer.parseInt(value.toString());
          break;
      case 9:
          slotCounting = Integer.parseInt(value.toString());
          break;
      case 10:
          serverUrlLink = (value.toString());
          break;
      case 11:
          webUrlLink = (value.toString());
          break;
  
  
      default:
          break;
      }
  
  }
  }
  </code></pre>
  
  <p>But, unfortunately, it is not working.</p>
  
  <p>I am getting this <strong>error</strong>. I looked around a lot but still haven't been able to find a solution to this.</p>
  
  <pre><code>SoapFault - faultcode: 'soap:Server' faultstring: 'Server was unable to process request. ---&gt; Object reference not set to an instance of an object.' faultactor: 'null' detail
  </code></pre>
  
  <p>Please help/suggest me how to fix the error.</p>