简体   繁体   中英

how to send large files to wcf service from windows service by using Buffered transfer mode

I am Developing an Application in which if the Client Uploads any document(any extension), it should be synced to the server.For this i have developed the windows service which is having wcf reference. Windows service runs in the background for particular interval and checks whether the file exists on server if not transfer the document.My problem is small files having size in bytes are transfering from client to the server but the files having the size more than 16kb are failed to transfer. Even i tried with increasing the maxarrayLength to 2GB in configuaration file. But it is not transfering.

this is the code in web.config file

<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true" />
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false" />
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding_ISyncUpService" closeTimeout="00:01:00"
      openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:01:00"
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
      maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
      messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed"
      useDefaultWebProxy="true">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
        maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None"
          realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<client>
  <endpoint address="http://localhost/WebSetup/Services/SyncUpService.svc"
   binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISyncUpService"
   contract="SyncUpService.ISyncUpService" name="BasicHttpBinding_ISyncUpService" />
</client>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

I am getting the following exception

There was an error deserializing the object of type System.IO.MemoryStream. 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

Thanks in advance

您可以尝试在服务和客户端Config文件上设置更大的MaxArrayLength属性。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM