Reputation: 1857
I am currently trying to create a webservice in a winform application using WCF, WShttpBinding. One of the methods returns a dictionary. The client side, an RTD Server will call this method to retrieve the dictionary.
For some reason, when the dictionary gets too large( 0.6MB +), a communication exception will be thrown. I have tried increasing the size of the following parameters both on the clientside and serverside, but it still willnot work. Can someone tell me what I am doing wrong? Thanks.
binding.MaxReceivedMessageSize
binding.MaxBufferPoolSize
binding.SendTimeout
binding.OpenTimeout
binding.ReceiveTimeout
binding.ReaderQuotas.MaxStringContentLength
binding.ReaderQuotas.MaxDepth
binding.ReaderQuotas.MaxBytesPerRead
Upvotes: 0
Views: 411
Reputation: 18743
Add a behavior
configuration in your App.config
files:
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<behaviors>
<endpointBehaviors>
<behavior name="MyClientBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
Note that 2147483647
is the max value and maybe you don't need that much.
And don't forget to reference the behavior in your services and endpoints:
<service name="SomeService" behaviorConfiguration="MyServiceBehavior">
<endpoint binding="WShttpBinding"
bindingConfiguration="MyBindingConf"
contract="SomeContract"/>
</service>
<endpoint binding="WShttpBinding"
bindingConfiguration="MyBindingConf"
behaviorConfiguration="MyServiceBehavior"
contract="SomeContract"
name="SomeName" />
Upvotes: 3