Why we cant return List in ASMX web services?

前端 未结 5 2019
忘掉有多难
忘掉有多难 2021-01-06 10:09

As developers know we cant return List with web services, we can only return lists with converting them to .ToArray(); I\'ve searched some, but cant ge

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-06 10:41

    There is nothing whatsoever preventing you from returning List from an ASMX web service. I have no idea why you believe that.

    What may be confusing you is that XML Schema (used by the WSDL) cannot describe "lists", per se. In fact, it cannot describe arrays, either. It can describe a series of repeating elements. All collections, including arrays, are returned as sets of repeating elements.

    On the client side, the client has no way to know whether the server returned List, T[], or IEnumerable, and no reason to care, either.

提交回复
热议问题