问题
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