I need to send my OrderItemList Class with OrderItem Class Array inside, I try this one but gives me error. Cannot serialize: foo.foo.OrderItemList@461e0bf8
Thanks for your time in advance.
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;
}
}
Implement Serializable in your class
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;
}
}