为什么无法使用Web服务返回字典? [英] Why cant a web service return a dictionary?

查看:159
本文介绍了为什么无法使用Web服务返回字典?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASMX web服务,它返回一个字典,但每次发布都会得到一个错误。

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


类型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]]是不支持,因为它实现了IDictionary

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


推荐答案

它会变成.......默认情况下,Web服务不支持IDictionaries,因此最好对正在解析的字典进行序列化。 这篇文章展示了如何序列化IDictionary

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

这篇关于为什么无法使用Web服务返回字典?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆