[英]how to send large files to wcf service from windows service by using Buffered transfer mode
我正在开发一个应用程序,如果客户端上传任何文档(任何扩展名),都应将其同步到服务器。为此,我开发了具有wcf参考的Windows服务。 Windows服务在后台运行特定的时间间隔,如果不传输文档,则检查文件在服务器上是否存在。我的问题是,字节大小的小文件正在从客户端传输到服务器,但是文件大小超过16kb的文件失败转让。 即使我尝试在配置文件中将maxarrayLength增加到2GB。 但是它没有转移。
这是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" />
我收到以下异常
反序列化类型为System.IO.MemoryStream的对象时发生错误。 读取XML数据时,已超出最大数组长度配额(16384)。 通过更改在创建XML阅读器时使用的XmlDictionaryReaderQuotas对象上的MaxArrayLength属性,可以增加此配额。
提前致谢
您可以尝试在服务和客户端Config文件上设置更大的MaxArrayLength属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.