我在指定主機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