tags:

views:

41

answers:

0

The application is implemented using WCF and NHibernate

The problem arises when you try to retrieve an array of objects in the stream. The error occurs not always and only on certain sites.

Service Config

<system.serviceModel>
  <bindings>

    <basicHttpBinding>
      <binding name="ServiceHttpBinding" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:20:00"
             sendTimeout="00:20:00" maxBufferSize="2147483647" maxBufferPoolSize="9223372036854775807" maxReceivedMessageSize="2147483647" transferMode="Buffered">
        <readerQuotas maxDepth="100" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="65536" maxNameTableCharCount="65536" />
      </binding>
      <binding name="StreamServiceHttpBinding" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:20:00"
               sendTimeout="00:20:00" maxBufferSize="2147483647" maxBufferPoolSize="9223372036854775807" maxReceivedMessageSize="2147483647" transferMode="Streamed">
        <readerQuotas maxDepth="100" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="65536" maxNameTableCharCount="65536" />
      </binding>
    </basicHttpBinding>

SercerSide methods to retrive objects

var serializer = new NetDataContractSerializer();
            var stream = new MemoryStream();
            var foundObjects = GetDAO().GetAll();
            serializer.WriteObject(stream, foundObjects);
            stream.Seek(0L, SeekOrigin.Begin);
            return stream;

The ClientSide code

public IList<DomainT> GetAll()
        {
            IList<DomainT> result;
            var streamedChannel = GetStreamChannel();
            using (streamedChannel as IDisposable)
            {
                using (var stream = streamedChannel.GetAll())
                {
                    var serializer = new NetDataContractSerializer();
                    result = (IList<DomainT>) serializer.ReadObject(stream);
                }
            }
            return result;
        }

Error occurs on serializer.ReadObject(stream) method. StackTrace

System.IO.IOException
в System.ServiceModel.Dispatcher.StreamFormatter.MessageBodyStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   в System.IO.BufferedStream.ReadByte()
   в System.Xml.EncodingStreamWrapper.ReadBOMEncoding(Boolean notOutOfBand)
   в System.Xml.EncodingStreamWrapper..ctor(Stream stream, Encoding encoding)
   в System.Xml.XmlUTF8TextReader.SetInput(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose)
   в System.Xml.XmlDictionaryReader.CreateTextReader(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose)
   в System.Runtime.Serialization.XmlObjectSerializer.ReadObject(Stream stream)
   в Client.Managers.BaseManager.AbstractManager`4.GetAll() в D:\Projects\IS_GIS\branches\lights\ITS.Client\Managers\BaseManager\AbstractManager.cs:строка 134

System.SreviceModel.CommunicationException
   в System.ServiceModel.Channels.HttpInput.WebResponseHttpInput.WebResponseInputStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   в System.ServiceModel.Channels.MaxMessageSizeStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   в System.ServiceModel.Channels.DetectEofStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   в System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count)
   в System.Xml.EncodingStreamWrapper.Read(Byte[] buffer, Int32 offset, Int32 count)
   в System.Xml.XmlBufferReader.TryEnsureBytes(Int32 count)
   в System.Xml.XmlBufferReader.GetBuffer(Int32 count, Int32& offset, Int32& offsetMax)
   в System.Xml.XmlUTF8TextReader.ReadText()
   в System.Xml.XmlUTF8TextReader.Read()
   в System.Xml.XmlBaseReader.ReadStartElement(String localName, String namespaceUri)
   в System.ServiceModel.Dispatcher.StreamFormatter.MessageBodyStream.Read(Byte[] buffer, Int32 offset, Int32 count)

System.IO.IOException
      в System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset, Int32 size) 
в System.ServiceModel.Channels.PreReadStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   в System.ServiceModel.Channels.HttpInput.WebResponseHttpInput.WebResponseInputStream.Read(Byte[] buffer, Int32 offset, Int32 count)