Can't transfer list<T> to web service?
        Posted  
        
            by iTayb
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by iTayb
        
        
        
        Published on 2010-04-13T09:57:32Z
        Indexed on 
            2010/04/13
            10:03 UTC
        
        
        Read the original article
        Hit count: 507
        
I have the same classes on my server and on my web service. I have the following WebMethod:
[WebMethod]
        public int CreateOrder(List<Purchase> p, string username)
        {
            o.Add(new Order(p,username));
            return o.Count;
        }
However the following code, run at server:
protected void CartRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        List<Purchase> l = ((List<Purchase>)Session["Cart"]);
        if (e.CommandName == "Order")
        {
            localhost.ValidateService WS = new localhost.ValidateService();
            WS.CreateOrder(l, Session["username"].ToString());
        }
    }
gives the following error: Argument '1': cannot convert from 'System.Collections.Generic.List<Purchase>' to 'localhost.Purchase[]'.
How can I transfer the list<Purchase> object to the web service?
Thank you very much.
© Stack Overflow or respective owner