【发布时间】:2011-09-29 10:15:52
【问题描述】:
一段时间以来,我一直在将数据从本地服务发送到 Web 服务时遇到问题,并且我尝试了很多文章,但它们似乎都没有帮助... 当我运行应用程序时,我收到以下错误: “读取 XML 数据时超出了最大数组长度配额 (16384)。可以通过更改创建 XML 读取器时使用的 XmlDictionaryReaderQuotas 对象的 MaxArrayLength 属性来增加此配额。”
这是我的 wcf 服务的 web.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IOnlineSyncService" maxReceivedMessageSize="50000000" maxBufferPoolSize="50000000" messageEncoding="Mtom">
<readerQuotas maxDepth="500000000" maxStringContentLength="500000000" maxArrayLength="500000000" maxBytesPerRead="500000000" maxNameTableCharCount="500000000" />
<security mode="None"/>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
我的 Windows 服务上的 App.config 如下:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<sources>
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" initializeData="FileLogWriter"/>
</sharedListeners>
</system.diagnostics>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IOnlineSyncService" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="50000000" maxBufferPoolSize="50000000" maxReceivedMessageSize="50000000" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="50000000" maxArrayLength="50000000" maxBytesPerRead="50000000" maxNameTableCharCount="50000000" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:65093/OnlineSyncService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IOnlineSyncService" contract="MyApp.OnlineSyncService.IOnlineSyncService" name="BasicHttpBinding_IOnlineSyncService" />
</client>
</system.serviceModel>
</configuration>
我从 Windows 应用程序调用它 (MySyncService.Upload_Cust_Data(fileContents, BranchID, MyFile.Name)) filecontents 被定义为一个 Byte()
我在两个文件上都定义了 MaxArrayLength 属性,但它仍然给我同样的错误。 我很喜欢这个:(
【问题讨论】:
标签: .net wcf windows-services