我需要发送带有OrderItem Class Array的OrderItemList类,我尝试了此操作但出现了错误。无法序列化:foo.foo.OrderItemList@461e0bf8
谢谢您的时间。
SoapObject request = new SoapObject(NAMESPACE, WebService);
OrderItemList orderItemList = null;
PropertyInfo pinfo = new PropertyInfo();
pinfo.name = "orderItems";
pinfo.namespace = NAMESPACE ;
pinfo.type = OrderItemList.class;
ArrayList<OrderItem> orderItemListT = new ArrayList<OrderItem>();
orderItemListT.add(new OrderItem(9,9,"",9,9,9,9));
orderItemList = new OrderItemList(orderItemListT);
request.addProperty(pinfo,orderItemList);
SoapSerializationEnvelope envelope =
new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.addMapping(NAMESPACE, "orderItems", orderItemList.getClass());
envelope.addMapping(NAMESPACE, "OrderItem", OrderItem.class);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
androidHttpTransport.call("http://tempuri.org/" + WebService , envelope);
OrderItem>
public class OrderItem {
public int ID;
public int OrderId;
public String FinalCode;
public int Quantity;
public double Price;
public double Discount;
public int Status;
public OrderItem(int id, int orderId, String finalCode ,int quantity, double price, double discount, int status) {
ID = id;
OrderId = orderId;
FinalCode = finalCode;
Quantity = quantity;
Price = price;
Discount = discount;
Status = status;
}
}
OrderItemList>
public class OrderItemList {
public ArrayList<OrderItem> OrderItemList;
public OrderItemList(ArrayList<OrderItem> orderItemList) {
OrderItemList = orderItemList;
}
}
最佳答案
在您的课程中实现可序列化
import java.io.Serializable;
public class OrderItem implements Serializable {
public int ID;
public int OrderId;
public String FinalCode;
public int Quantity;
public double Price;
public double Discount;
public int Status;
public OrderItem(int id, int orderId, String finalCode ,int quantity, double price, double discount, int status) {
ID = id;
OrderId = orderId;
FinalCode = finalCode;
Quantity = quantity;
Price = price;
Discount = discount;
Status = status;
}
}
关于android - KSOAP 2复杂类,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11386021/