将数据从windows服务发送到WCF - MaxArrayLength错误
问题描述:
我在将数据从本地服务发送到Web服务一段时间后有问题,并且我尝试了很多文章,但它们似乎都没有帮助。 .. 当我运行该应用程序时,出现以下错误: “读取XML数据时超出了最大数组长度限制(16384)。可以通过更改创建时使用的XmlDictionaryReaderQuotas对象的MaxArrayLength属性来增加此配额XML阅读器“。将数据从windows服务发送到WCF - 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>
我的App.config在我的Windows服务如下:
<?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被定义为一个字节()
我在两个文件上都定义了MaxArrayLength属性,但它仍然给我同样的错误。 我拿起武器与此一:(
答
你试过在WCF服务取消绑定的名称,并将其设置为空? 所以结合覆盖默认绑定。
既然你不” t指定端点我假设wcf服务使用默认绑定配置。