https://social.microsoft.com/Forums/zh-CN/c548f38a-4e9d-486f-b46d-ef3719cd0c26/-xml-xmldictionaryreaderquotas-maxarraylength-?forum=wcfzhchs
http://stackoverflow.com/questions/7470530/problem-with-large-requests-in-wcf
遇到这个问题的时候,一开始按照大部分人说的设置MaxArrayLength的最大值为一个比较大的数,但是发现还是报错,后面折腾了好久找到了办法
简而言之,就是把服务器端的binding 和endpoint 节点的name属性给去掉
现在我的客户端配置文件是:
<?xml version="1.0"?> <configuration> <connectionStrings> <add name="SafetyValveEntity" connectionString="metadata=res://*/SafetyValve.csdl|res://*/SafetyValve.ssdl|res://*/SafetyValve.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.sqlexpress;Initial Catalog=SafetyValve;Integrated Security=False;User Id=sa;Password=Dayawan123;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"/> </connectionStrings> <startup useLegacyV2RuntimeActivationPolicy="true"><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_ISafetyValve" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="5242880000" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" > <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="409600" maxNameTableCharCount="2147483647" /> <security mode="None"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="http://cc.liicon.com:8003/SafetyValve.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISafetyValve" contract="ServiceReference1.ISafetyValve" name="BasicHttpBinding_ISafetyValve" /> </client> </system.serviceModel> </configuration>
服务器端的是:
<?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <!-- For more information on Entity Framework configuration,visit http://go.microsoft.com/fwlink/?LinkID=237468 --> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,EntityFramework,Version=6.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089" requirePermission="false" /> </configSections> <system.web> <compilation debug="true" targetFramework="4.0"> <assemblies> <add assembly="System.Data.Entity,Version=4.0.0.0,PublicKeyToken=b77a5c561934e089" /> </assemblies> </compilation> </system.web> <system.serviceModel> <bindings> <basicHttpBinding> <binding closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="5242880000" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" > <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="409600" maxNameTableCharCount="2147483647" /> <security mode="None"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="http://cc.liicon.com:8003/SafetyValve.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISafetyValve" contract="ServiceReference1.ISafetyValve" /> </client> <behaviors> <serviceBehaviors> <behavior> <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 --> <serviceMetadata httpGetEnabled="true" /> <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 --> <serviceDebug includeExceptionDetailInFaults="true" /> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true" /> <!-- 若要在调试过程中浏览 Web 应用程序根目录,请将下面的值设置为 True。 在部署之前将该值设置为 False 可避免泄露 Web 应用程序文件夹信息。 --> <directoryBrowse enabled="true" /> </system.webServer> <connectionStrings> <add name="SafetyValveEntities" connectionString="metadata=res://*/SafetyValve.csdl|res://*/SafetyValve.ssdl|res://*/SafetyValve.msl;provider=System.Data.SqlClient;provider connection string="data source=.sqlexpress;initial catalog=SafetyValve;user id=sa;password=Dayawan123;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" /> </connectionStrings> <entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory,EntityFramework" /> <providers> <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices,EntityFramework.SqlServer" /> </providers> </entityFramework> </configuration>
注意服务器端的binding 和 endpoint 和客户端不同哟,把name去掉了
奇怪的解决办法,但是好歹可以解决 (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|