我们有一个现有的应用程序,其中一个DTO对象的属性类型为IDictionary<string, object>
。在WCF中序列化IDictionary <字符串,对象>
我现在试图通过WCF服务公开这个对象。这在某些情况下有效,但在一般情况下不起作用。为了说明问题,可以考虑以下两种方法:
[OperationContract]
public IDictionary<string, object> Test1()
{
return new Dictionary<string, object>
{
{ "testkey1", "newstringvalue"},
};
}
[OperationContract]
public IDictionary<string, object> Test2()
{
return new Dictionary<string, object>
{
{ "testkey1", "newstringvalue"},
{ "testkey2", new object [] { "one" , "two", "three", } }
};
}
方法的Test1()正常工作,但是当我打电话的Test2(),我得到的客户端上的一个奇怪的运行时错误:
The request channel timed out while waiting for a reply after 00:01:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
Inner exception: The remote server returned an error: (504) Gateway Timeout.
尽管异常是即时引发的,即。我实际上并不需要等一分钟才能做出回应。服务器上没有显示错误。
我怀疑这起源于串行器无法序列化对象[]的事实,但这不是错误所指示的。
所以我的问题是:
- 这到底是怎么回事?
- 我该如何解决这个问题,以便我可以正确地序列化我的对象?
谢谢。
它必须是一个对象吗?如果它是一个字符串集合不能使用列表,数组等? – timothyclifford 2010-11-19 03:38:37