[英]WCF service dataContractSerializer maxItemsInObjectGraph in web.config
I am having issues specifying the dataContractSerializer maxItemsInObjectGraph in host's web.config. 我在主机的web.config中指定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>
The above has no effect on my data pull. 以上对我的数据拉动没有影响。 The server times out because of the large volume of data.
由于数据量很大,服务器超时。
I can however specify the max limit in code and that works 但是,我可以在代码中指定最大限制并且有效
[ServiceBehavior(MaxItemsInObjectGraph=2147483646, IncludeExceptionDetailInFaults = true)]
public abstract class MyService : MyService
{
blah...
}
Does anyone know why I can't make this work through a web.config setting? 有谁知道为什么我不能通过web.config设置来完成这项工作? I would like to keep in the web.config so it is easier for future updates.
我想保留在web.config中,以便将来更新。
In your behavior section, add an endpoint behavior with the dataContractSerializer, like so: 在您的行为部分中,使用dataContractSerializer添加端点行为,如下所示:
<endpointBehaviors>
<behavior name="LargeQuotaBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
</endpointBehaviors>
Then modify your endpoint to use this behavior like so: 然后修改您的端点以使用此行为,如下所示:
<endpoint address="http://localhost/myservice/"
binding="webHttpBinding"
bindingConfiguration="webHttpBinding1"
contract="MyNamespace.IMyService"
bindingNamespace="MyNamespace"
behaviorConfiguration="LargeQuotaBehavior">
This should solve your problem. 这应该可以解决您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.