Return type list from web service

I want to return a list of some resources from a web service. The web service seems to make the list return as an array.

The next three lines work part of the array, but I canโ€™t figure out how to get it back to a list like "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 to be entered using XmlInclude, but still do not go.

How to get a web service to return a list of my InventoryToSync or how to convert an array back to Inventory to Sync.

+6
source share
1 answer

In the Add Service Link dialog box, click Advanced, and select List<T> as the type of collection.

enter image description here

+7
source

Source: https://habr.com/ru/post/947164/


All Articles