2

OrderItemクラス配列を含む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;
    }
}
4

1 に答える 1

2

クラスに Serializable を実装する

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;
    }
}
于 2012-12-04T16:28:38.900 に答える