简体   繁体   English

如何通过使用缓冲传输模式将大文件从Windows服务发送到WCF服务

[英]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. 我正在开发一个应用程序,如果客户端上传任何文档(任何扩展名),都应将其同步到服务器。为此,我开发了具有wcf参考的Windows服务。 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. Windows服务在后台运行特定的时间间隔,如果不传输文档,则检查文件在服务器上是否存在。我的问题是,字节大小的小文件正在从客户端传输到服务器,但是文件大小超过16kb的文件失败转让。 Even i tried with increasing the maxarrayLength to 2GB in configuaration file. 即使我尝试在配置文件中将maxarrayLength增加到2GB。 But it is not transfering. 但是它没有转移。

this is the code in web.config file 这是web.config文件中的代码

<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. 反序列化类型为System.IO.MemoryStream的对象时发生错误。 The maximum array length quota (16384) has been exceeded while reading XML data. 读取XML数据时,已超出最大数组长度配额(16384)。 This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader 通过更改在创建XML阅读器时使用的XmlDictionaryReaderQuotas对象上的MaxArrayLength属性,可以增加此配额。

Thanks in advance 提前致谢

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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