Why cant a web service return a dictionary?

只愿长相守 提交于 2019-12-24 08:16:00

问题


I have an ASMX web service that returns a dictionary but get an error each time it is posting

type System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[BL.Customer, BL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] is not supported because it implements IDictionary


回答1:


Best to post the error you are actually recieving but as it goes....... IDictionaries are not supported by web services by default so it is best to serialise the dictionary you are parsing. This article shows how to serialise the IDictionary




回答2:


Even if you could serialize the dictionary, SOAP has no representation of a dictionary-type structure. The client would have no idea that the service was sending a dictionary.



来源:https://stackoverflow.com/questions/13838592/why-cant-a-web-service-return-a-dictionary

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!