I want to return a list of some inventory from a web service. It seems that the web service forces the the list to return as an array.
In the following 3 lines the array portion works, but I can't figure out how to cast it back to a list of type "InventoryToSync"
List<InventoryToSync> inventoryList = new List<InventoryToSync>();
Array theArray = myIcsSyncService.ReturnInventoryToSyncDictionary();
inventoryList = myIcsSyncService.ReturnInventoryToSyncDictionary().Cast<InventoryToSync>();
Here is my web method:
[WebMethod]
[System.Xml.Serialization.XmlInclude(typeof(InventoryToSync))]
public List<InventoryToSync> ReturnInventoryToSyncDictionary()
{
Inventory inventory = new Inventory();
return inventory.GetInventoryList();
}
I tried to force the type with XmlInclude, but still no go.
How to I force the web service to return a list of my InventoryToSync, or how do I convert the array back to Inventory to Sync.
In the "Add Service Reference" dialog, click "Advanced" and choose to use List<T>
as the collection type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With