将数据从Windows服务发送到WCF - MaxArrayLength错误

时间:2011-09-29 10:15:52

标签: .net wcf windows-services

我在将数据从本地服务发送到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属性,但它仍然给出了同样的错误。 我和这个人站在一起:(

1 个答案:

答案 0 :(得分:0)

您是否尝试删除wcf服务中的绑定名称,并将其设置为空白? 因此绑定会覆盖默认绑定。

由于您没有指定端点,我假设wcf服务使用默认绑定配置。