我在指定主机web.config中的dataContractSerializer maxItemsInObjectGraph时遇到问题。web.config中的WCF服务dataContractSerializer maxItemsInObjectGraph
<behaviors>
<serviceBehaviors>
<behavior name="beSetting">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="True" />
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="MyNamespace.MyService"
behaviorConfiguration="beSetting" >
<endpoint address="http://localhost/myservice/"
binding="webHttpBinding"
bindingConfiguration="webHttpBinding1"
contract="MyNamespace.IMyService"
bindingNamespace="MyNamespace">
</endpoint>
</service>
</services>
以上对我的数据拉动没有影响。由于大量数据,服务器超时。
我可以然而,在代码中指定的最大限额和工作
[ServiceBehavior(MaxItemsInObjectGraph=2147483646, IncludeExceptionDetailInFaults = true)]
public abstract class MyService : MyService
{
blah...
}
有谁知道为什么我不能通过一个web.config设置,使这项工作?我想保留在web.config中,以便将来的更新更容易。
我也有这个问题。我想知道为什么没有人回答?感谢能够在代码中设置'ServiceBehavior'的提示,它至少可以让我感动。 – jocull 2011-07-05 06:00:54
你知道maxItemsInObjectGraph只定义了响应中允许的元素的总数,而不是直接响应的大小是啊? (我想如果没有指定它默认为60k xml元素) – 2011-08-10 14:42:32
戴夫,你的问题是否回答了?如果给定的答案解决了您的问题,请将其标记为如此。 – Bardia 2012-12-17 19:56:56