locked
The formatter threw an exception while trying to deserialize the message in WCF RRS feed

  • Question

  • User-1964325223 posted

    I have a WCF application. Which extract value from a txt file and save into database. When the file size is upto 16KB then its working fine. When when its goes above 16KB the the Service throws an error.

    The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:f. The InnerException message was 'There was an error deserializing the object of type System.Byte[]. The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 24597.'.  Please see InnerException for more details.


    In the web.config : MaxArrayLength property is set to 2147483647

    Tuesday, January 29, 2013 12:58 AM

Answers

  • User-1964325223 posted

    Hi,

    Its done..I had changed the Binding Type from basicHttpBinding to WSHttpBinding and its working fine.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 13, 2013 12:05 AM

All replies

  • User-1662538993 posted

    Try setting up MaxArrayLength = 2147483647 in your web config file of your wcf service.


    Tuesday, January 29, 2013 5:22 PM
  • User-1000095884 posted

    Hi,

    Please make sure you have apply the bindingconfiguration to your endpoint for both service and client side.

    <endpoint bindingConfiguration="yourbindingconfiguration" binding="basicHttpBinding" contract="yourcontract" />


    If the issue still exists, please post your config here.

    Best Regards.

    Tuesday, January 29, 2013 9:11 PM
  • User-1964325223 posted

    Hi kushalrdalal

    Thanx for ur comment but I had already mention that in web.config i had written MaxArrayLength = 2147483647. I does't works.

    Wednesday, January 30, 2013 12:22 AM
  • User-1964325223 posted

     Hi Haixia Xie,

    This is my web.config:
    <system.serviceModel>
    <bindings>
    <basicHttpBinding>
    <binding name="BasicHttpBinding_ISwiftBacsService" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
    closeTimeout="00:10:00" transferMode="Streamed" openTimeout="00:10:00" sendTimeout="00:10:00" messageEncoding="Mtom">
    <readerQuotas maxDepth="32"
    maxStringContentLength="2147483647"
    maxArrayLength="2147483647"
    maxBytesPerRead="2147483647"
    maxNameTableCharCount="2147483647"
    />
    <security mode="None"></security>
    </binding>
    </basicHttpBinding>
    </bindings>
    <client>
    <endpoint address="http://192.168.1.26:8082/SwiftBacsService.svc"
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISwiftBacsService"
    contract="SwiftBacsWcfService.ISwiftBacsService" name="BasicHttpBinding_ISwiftBacsService" />
    </client>
    <behaviors>
    <endpointBehaviors>
    <behavior name="clintbihaviour">
    <dataContractSerializer maxItemsInObjectGraph ="2147483647"/>
    </behavior>
    </endpointBehaviors>
    </behaviors>
    </system.serviceModel>

    <system.web>
       <httpRuntime maxRequestLength="65536"/>
    </system.web>

    But in the binding if i remove messageEncoding="Mtom" then following error occurs:
    System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (413) Request Entity Too Large.

    Wednesday, January 30, 2013 12:29 AM
  • User-1000095884 posted

    Hi,

    But in the binding if i remove messageEncoding="Mtom" then following error occurs:
    System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (413) Request Entity Too Large.

    Does it works as expected before you remove this?

    How do you host the service? If you host the service in IIS, you may take a look at a post here to check if the issue is related to IIS request readquota setting. Another post talks on similar issue.

    #(413) Request Entity Too Large

    http://www.codeproject.com/Articles/521725/413-Request-Entity-Too-Large

    Best Regards.

    Monday, February 4, 2013 8:59 PM
  • User-1964325223 posted

    Hi Haixia,

     No, before i remove that follwing error was there :

    The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:f. The InnerException message was 'There was an error deserializing the object of type System.Byte[]. The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 24597.'.  Please see InnerException for more details.


    I had tried to increase the uploadreadaheadsize in iis7 but unable to execute the command(According to the instruction http://www.codeproject.com/Articles/521725/413-Request-Entity-Too-Large) successfully.

    I had made a site in my IIS and hosted my WCF application there. Is there any option so that i can attched the project so that you can run my sample code there.

    Tuesday, February 5, 2013 1:40 AM
  • User-1000095884 posted

    Hi,

    You can upload the simplified project to skydrive and post the link here and provide the steps on how do you host the application in IIS.

    Best Regards.

    Tuesday, February 5, 2013 8:28 PM
  • User-1964325223 posted

    Hi,

    Its done..I had changed the Binding Type from basicHttpBinding to WSHttpBinding and its working fine.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 13, 2013 12:05 AM