0
有沒有人知道一個解決方案作爲參數發送對象具有對象有成員? 我試圖做這樣的事情:KSOAP ANDROID - 發送複雜對象 - 對象具有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;
}
}
但它總是與某種目的: 了java.lang.RuntimeException:無法序列:客戶端:客戶端@ 416802f0
我的測試對象看起來像這樣:
public class Order extends ContractObject {
public int id;
public Client client;
public SoapArray<ProductType> contentProductType;
public DeliveryType deliveryType;
public PaymentType paiementType;
public boolean isTracked;
public Address deliveryAddress;
public Address billingAddress;
public String comments;
}
它不起作用^^ 格式化的XML包含n0:ContractObject作爲服務器期望ContractObject ... – Dam 2012-05-19 16:35:11
所以嵌套對象不是解決方案.. – Dam 2012-05-19 16:37:38