我們正在嘗試將大型XML字符串發送到WCF服務的方法和我們得到的錯誤WCF配置maxStringContentLength似乎並不奏效
最大字符串的內容長度 配額(8192 )已被超出,而 讀取XML數據。
錯誤提示增加maxstringcontentlength
儘管我們不確定我們是否應該在客戶端或服務器端或兩者都執行此操作。我們嘗試了兩種方式,但我們似乎仍然得到了錯誤。我將在下面發佈客戶端和服務配置。我假設他們中的一個或兩個都有問題,阻止了它的工作。
有什麼建議嗎?
客戶:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ITESTService"
closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8"
transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="4096"
maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint name="BasicHttpBinding_ITESTService"
address="http://localhost/TESTService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_ITESTService"
contract="TESTService.ITESTService" />
</client>
</system.serviceModel>
服務器:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding
name="BasicHttpBinding_Service1"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="4096" maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="TESTService">
<endpoint name="BasicHttpBinding_Service1"
address="http://localhost/TESTService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_Service1"
contract="ITESTService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
我不知道這些最大值是正確的,我會去的: `MAXBUFFERSIZE = 2147483647, MaxBufferPoolSize = 524288, MaxReceivedMessageSize = 2147483647, ReaderQuotas = new XmlDictionaryReaderQuotas { MaxDepth = 32, MaxStringContentLength = 8192, MaxArrayLength = 16384, MaxBytesPerRead = 4096, MaxNameTableCharCount = 1638 } – DanielV 2017-09-28 09:08:05