2012-04-01 6 views
0

Kennt jemand eine Lösung, um als ein Objekt ein Objekt zu senden, das Mitglied hat? Ich habe versucht, so etwas zu tun:KSOAP ANDROID - Komplexes Objekt senden - Objekt hat ObjectMember


public abstract class ContractObject implements KvmSerializable { 
    public ContractObject() { 
    } 

    public abstract void fill(SoapObject soapObject); 

    public Object getProperty(int intPropertyIndex) { 
     Object val = null; 
     try { 
      val = this.getClass().getFields()[intPropertyIndex].get(this); 
     } catch (IllegalAccessException e) { 
      e.printStackTrace(); 
     } 
     if(val != null) { 
      if(val.getClass().isPrimitive()) { 
       return val; 
      } 
      else { 
       return ((ContractObject) val).toPropertyInfo(); 
      } 
     } else { 
      return null; 
     } 
    } 

    public int getPropertyCount() { 
     return this.getClass().getFields().length; 
    } 

    public void getPropertyInfo(int intPropertyIndex, Hashtable arg1, PropertyInfo info) { 
     Field field = this.getClass().getFields()[intPropertyIndex]; 
     info.name = field.getName(); 
     info.type = field.getType(); 
    } 

    public void setProperty(int intPropertyIndex, Object objectPropertyNewValue) { 
     Field field = this.getClass().getFields()[intPropertyIndex]; 
     try { 
      field.set(this, objectPropertyNewValue); 
     } catch (IllegalAccessException e) { 
      e.printStackTrace(); 
     } 
    } 

    public PropertyInfo toPropertyInfo() { 
     PropertyInfo value = new PropertyInfo(); 
     value.setName(this.getClass().getName()); 
     value.setType(this.getClass()); 
     value.setValue(this); 
     return value; 
    } 

} 

Aber es ist immer mit einem gewissen zu Ende: java.lang.RuntimeException: serialisiert Kann nicht: Client: Client @ 416802f0


Mein Testobjekt Sieht so aus:



Antwort

0

Ich denke, Ihr eigentliches Problem die SoapArray<ProductType> als Mitglied der Order Klasse senden wird.

Beantworten Sie Ihre Frage: verwenden Sie addMapping? Werfen Sie einen Blick auf diese: Android Ksoap2 Setting the namespace for nested (children) types

+0

Es funktioniert nicht ^^ die formatierte xml enthält n0: ContractObject als Server erwarten ContractObject ... – Dam

+0

So geschachtelte Objekt sind nicht die Lösung .. – Dam

Verwandte Themen