有人知道一个解决方案,作为参数发送一个Object有Object的成员吗? 我试着做这样的事情:
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:无法序列化:客户端:Client @ 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;
}
答案 0 :(得分:0)
我认为您的真正问题是SoapArray<ProductType>
成员发送Order
。
回答你的问题:你使用addMapping
吗?看看这个:Android Ksoap2 Setting the namespace for nested (children) types