How do I avoid this OData limitation?

For the url:
http://services.odata.org/Northwind/Northwind.svc/Employees?$expand=Territories,Orders,Orders/Order_Details&$top=5
I'm getting:
Microsoft.Data.OData.ODataException occurred
Message=The maximum number of bytes allowed to be read from the stream has been exceeded. After the last read operation, a total of 1049051 bytes has been read from the stream; however a maximum of 1048576 bytes is allowed.
Source=Microsoft.Data.OData
StackTrace:
at Microsoft.Data.OData.MessageStreamWrapper.MessageStreamWrappingStream.IncreaseTotalBytesRead(Int32 bytesRead)
at Microsoft.Data.OData.MessageStreamWrapper.MessageStreamWrappingStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at Microsoft.Data.OData.BufferingReadStream.Read(Byte[] userBuffer, Int32 offset, Int32 count)
at System.IO.StreamReader.ReadBuffer(Char[] userBuffer, Int32 userOffset, Int32 desiredChars, Boolean& readToUserBuffer)
at System.IO.StreamReader.Read(Char[] buffer, Int32 index, Int32 count)
at System.Xml.XmlTextReaderImpl.ReadData()
at System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow(Int32 curPos, Char quoteChar, NodeData attr)
at System.Xml.XmlTextReaderImpl.ParseAttributes()
at System.Xml.XmlTextReaderImpl.ParseElement()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlTextReaderImpl.Read()
at Microsoft.Data.OData.Atom.BufferingXmlReader.ReadInternal(Boolean ignoreInStreamErrors)
at Microsoft.Data.OData.Atom.BufferingXmlReader.ReadNextAndCheckForInStreamError()
at Microsoft.Data.OData.Atom.BufferingXmlReader.ReadInternal(Boolean ignoreInStreamErrors)
at Microsoft.Data.OData.Atom.BufferingXmlReader.Read()
at System.Xml.XmlReader.SkipSubtree()
at System.Xml.XmlReader.Skip()
at Microsoft.Data.OData.Atom.ODataAtomEntryAndFeedDeserializer.FindTypeName()
at Microsoft.Data.OData.Atom.ODataAtomReader.ReadEntryStart()
at Microsoft.Data.OData.Atom.ODataAtomReader.ReadAtEntryEndImplementation()
at Microsoft.Data.OData.ODataReaderCore.ReadImplementation()
at Microsoft.Data.OData.ODataReaderCore.ReadSynchronously()
at Microsoft.Data.OData.ODataReaderCore.InterceptException[T](Func`1 action)
at Microsoft.Data.OData.ODataReaderCore.Read()
at WindwardReportsDrivers.net.windward.datasource.odata.ODataUtilities.ReadEntryList(String uri, WrCredentials credentials, CONNECT_MODE protocol, IEdmModel model, ODataVersion oDataVersion)
InnerException:
Any ideas how to get this data?
thanks - dave
Who will win
The International Collegiate Programming Championships?

No - this limit is meant to guard the client from malicious servers. It is possible to send valid OData feed which will consume lot of memory to parse. This can be done on the XML level or on the OData level. This limit guards against both.
Servers have other ways to limit amount of data returned to the client, the reason there is to guard against expensive query execution
In general a good way to look at OData is to think about it as the "minimum necessary protocol" to do what is needed. We try to keep it that way anyway. It's also stateless (REST...). So the more coupling between client and server, the worse... so to say.
I can imagine having an HTTP header for this purpose, but I don't think that lot of clients would be interested in it.
I think you should approach this limit from the security point of view (that's what it's for). Set it to the maximum amount of memory you're willing to give up to process the response. At least roughly (the memory consumption should be linear to the size
of the input, cases where it's not are guarded by the other options on the MessageQuotas).
Thanks,
Vitek Karas [MSFT]

Similar Messages

Maybe you are looking for