我已经创建了一个像这样的 EndpointAddress
EndpointAddress address = new EndpointAddress("http://example.com/services/OrderService.svc");
但我无法以编程方式将行为添加到此端点。
该行为如下:
<behaviors>
<endpointBehaviors>
<behavior name="NewBehavior">
<dataContractSerializer maxItemsInObjectGraph="6553600" />
</behavior>
</endpointBehaviors>
</behaviors>
在服务器上,您必须将其添加到 ServiceBehavior 属性中:
[ServiceBehavior(MaxItemsInObjectGraph = int.MaxValue)]
在客户端上,您必须将其应用到端点。在此示例中,您可以看到如何将其添加到 ChannelFactory 中的所有端点:
var factory = new ChannelFactory<IInterface>(...);
foreach (OperationDescription op in factory.Endpoint.Contract.Operations)
{
var dataContractBehavior = op.Behaviors.Find<DataContractSerializerOperationBehavior>();
if (dataContractBehavior != null)
{
dataContractBehavior.MaxItemsInObjectGraph = int.MaxValue;
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)