We have a REST service with attributes [WebGet(UriTemplate ="...", BodyStyle =WebMessageBodyStyle.Bare, ResponseFormat =WebMessageFormat.Xml)]
Normally it worked fine. But for particular data it has a huge response that was truncated.
The size returned in a few attempts in IE browser was 2196456, in Chrome slightly different 2195397.
After a search in google I found http://forums.asp.net/post/4948029.aspx, that has a number of suggestions.
For WCF service that will transfer large amount of data in operations, here are the configuration settings you need to check:
- the maxReceivedMessageSize attribute of the certain element(in your case, that's the webHttpbinding)
#
http://msdn.microsoft.com/en-us/library/bb412176.aspx
- The settings (under the elements) which has control over the maxarrayLength, maxStringLength ,etc...
#
http://msdn.microsoft.com/en-us/library/ms731325.aspx
- The DataContractSerializer behavior which has a MaxItemsInObjectGraph property. You can configure it via ServiceBehavior of your WCF service
#DataContractSerializer.MaxItemsInObjectGraph Property
http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractserializer.maxitemsinobjectgraph.aspx
- And if your WCF service is hosted in ASP.NET/IIS web application, you also need to enlarge the "maxRequestLength" attribute of the element (under <system.web> section).
#httpRuntime Element (ASP.NET Settings Schema)
http://msdn.microsoft.com/en-us/library/e1f13641.aspx
After a few attempts my collegue found that our problem was caused by
#DataContractSerializer.MaxItemsInObjectGraph Property
http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractserializer.maxitemsinobjectgraph.aspx
<behavior name="MyOperationBehavior">
< dataContractSerializer maxItemsInObjectGraph ="2196456" />
</behavior>
