首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >wcf配置maxStringContentLength似乎不起作用。

wcf配置maxStringContentLength似乎不起作用。
EN

Stack Overflow用户
提问于 2011-01-29 01:21:51
回答 4查看 15.7K关注 0票数 4

我们试图向WCF中的服务方法发送一个大的xml字符串,并且我们得到了错误

读取XML数据时已超出最大字符串内容长度配额(8192)。

这个错误意味着增加maxstringcontentlength,尽管我们不确定我们是否应该在客户端或服务器端,或者两者兼而有之。我们试过把这两种方法都放进去,但似乎还是会犯错误的。我将把客户和服务吐露在下面。我想他们中的一人或两人都有问题来阻止他们的工作。

有什么建议吗?

客户端:

代码语言:javascript
复制
<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>

服务器:

代码语言:javascript
复制
<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>
EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2011-01-29 10:33:13

线程详细说明如何正确指定服务器和客户端上的绑定设置,以更改MaxStringContentLength。

另一个线程还提供了一个关于使用readerQuotas的清晰而高效的答案。

票数 0
EN

Stack Overflow用户

发布于 2011-11-04 11:18:17

尝试添加“默认”绑定(没有指定任何名称)。将readerQuota设置添加到此绑定中。

然后,您甚至可以从实际使用的命名绑定中删除readerQuota设置。

这对我有效(虽然我不知道为什么WCF忽略了正确命名绑定上的readerQuotas )

票数 2
EN

Stack Overflow用户

发布于 2013-06-25 07:17:29

“默认”绑定选项对我有效。我尝试在命名的maxStringContentLength中自定义WebHttpBinding值,但由于某种原因,WCF没有选择它。最后,我跟踪了D.Tiemstra的工作,然后它开始工作。

代码语言:javascript
复制
    <webHttpBinding>         
    <binding  maxReceivedMessageSize="2147483647" > 
      <readerQuotas maxDepth="2147483647"
       maxStringContentLength="2147483647"
       maxArrayLength="2147483647"
       maxBytesPerRead="2147483647"
       maxNameTableCharCount="2147483647" />
    </binding>
  </webHttpBinding>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4834489

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档