Why would a WCF method's return type be changed from a generic collection to an array?

前端 未结 4 1527
一整个雨季
一整个雨季 2021-01-21 13:23

I have a WCF service method which I have written for return type as collection type.

But if I generate a proxy class and consume the method from the client the methods r

4条回答
  •  旧巷少年郎
    2021-01-21 14:04

    Remember - WCF is also an interoperable system, e.g. your other end of the wire could be a PHP or Java or Ruby client which will not be able to understand the .NET generic list!

    You can specify you want generic lists with the two options Andrew and Jimmie have mentioned - this works, if and only if you also use the DataContractSerializer (which is the default choice for WCF). However, if your service and/or data contract for whatever reason needs to use the XmlSerializer instead, then these settings won't help - your lists will be turned into arrays once again.

    So try these options shown, and if they work for you - great! But be aware that there are good reasons why your generic list might just have to be turned into a more interoperable array of objects.

    Marc

提交回复
热议问题