发送一个Hashtable到Webservice [英] Sending a Hashtable to a Webservice
问题描述
我试图发送具有通用键和值类型的项目列表到asp.net webservice。
我该怎么做?
我尝试使用列表<字典< String,String>>
,但这不工作。我没有得到例外,但是当我在webserivice中断时,我的集合是空的。
数据可能如下所示:
{Data:{fieldtype:integer,isrequired:true,isrequirederror:无效数据}
但是正如我所说,键是通用的,有时候还有更多的属性,有时不是。
Im trying to send a List of Items with generic Keys and Value Types to a asp.net webservice.
How can i do this?
I tried it with List<Dictionary<String, String>>
, but this doens't work. I do not get an exception, but when i break in the webserivice, my collection is null.
The Data could look like this:
{"Data":{"fieldtype":"integer","isrequired":true,"isrequirederror":"Invalid Data"}}.
But as i said, the Keys are generic, sometimes there are more properties, sometimes not.
Thx alot
这篇文章无法帮助我的btw:
如何将散列表发送到asmx webservice?
This post couldn't help my btw: How to send a hashtable to an asmx webservice?
推荐答案
p>如果您要在服务中引入任何类型的泛型,从SOA和WCF的困难时期开始,从序列化/反序列化问题开始,并完成互操作性问题。
You are going to have hard times with SOA and WCF in particular if you want to introduce any kind of generics in your service - starting from serialization/deserialization issues and finishing interoperability issues.
不要使用通用参数。由于读/写操作性能,哈希表(或词典)仅在进程内使用中才有意义。如果你想通过电线传输这样一种格式的东西,可以使用如下结构:
对(/ string)串的列表
Don't use generic parameters. Hashtable (or Dictionary) makes sense only within in-process usage due to read/write operations performance. If you want to transmit something in such format over the wire, use something like the following structure: List of pairs (string, string).
这篇关于发送一个Hashtable到Webservice的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!