I have a basic WCF service that spans multiple xml. Some of the xml is a list:
<Root>
<Products>
<Product>
<SKU>1234</SKU>
<Price>2533</Price>
<ProductName>Brown Shows</ProductName>
<Quantity>1</Quantity>
</Product>
<Product>
<SKU>345345</SKU>
<Price>2345</Price>
<ProductName>Red Shows</ProductName>
<Quantity>1</Quantity>
</Product>
</Products>
</Root>
In my class that this persists, I:
[DataMember(Name = "Products", Order = 4, IsRequired = false, EmitDefaultValue = false)]
public List<Product> products;
Then in my Product class, I have SKU, Price, ProductName, and Quantity. Other elements from the list are not set in my class, but it does not look as if hm filled my list. Did I miss something?
Heres my Product Class
public class Product
{
[DataMember(Name = "SKU", Order = 0)]
public string sku;
[DataMember(Name = "Price", Order = 1, IsRequired = false, EmitDefaultValue = false)]
public int price;
[DataMember(Name = "ProductName", Order = 2, IsRequired = false, EmitDefaultValue = false)]
public string productName;
[DataMember(Name = "Quantity", Order = 3, IsRequired = false, EmitDefaultValue = false)]
public int quantity;
[DataMember(Name = "Available", Order = 1, IsRequired = false, EmitDefaultValue = false)]
public string available;
}
source
share