I have one web service:
public class Product
{
public int ProductId { get; set; }
public string ProductName { get; set; }
}
public class Service : System.Web.Services.WebService
{
public Service () {
}
[WebMethod]
public List<Product> GetItems()
{
List<Product> productList = new List<Product>()
{
new Product{ProductId=1,ProductName="Pencil"},
new Product{ProductId=2,ProductName="Pen"}
};
return productList;
}
and in asp.net application I consume it as:
localhost.Service s = new localhost.Service();
List<localhost.Product> k = new List<localhost.Product>();
k = s.GetItems().ToList();
Now my question is: do I need to serialize my web method when I return custom types? when should we serialize? is it necessary at all, if so, what are the conditions?
source
share