I have one webservice:
public class Product
{
public int ProductId { get; set; }
public string ProductName { get; set; }
}
public class Service : System.Web.Services.WebService
{
public Service () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[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 a asp.net application I am consuming it like:
localhost.Service s = new localhost.Service();
List<localhost.Product> k = new List<localhost.Product>();
k = s.GetItems().ToList(); // i am getting the values here.
now my question is do I need to serialize my webmethod as i am returning custom types? when should we serialize ? is it necessary at all, if yes , then what are the conditions?