zoukankan      html  css  js  c++  java
  • WCF数据交互时长度超过8192

    wcf项目里面,客户端的某个函数执行时可能需要上传13000个字符到服务器。

    按照常规的接口+客户端调用写好代码之后,出现了这么个错误:

    网上查了很多资料,没有能够一步到位解决问题的。花了2个小时,总算是扁出来了。

    需要同时修改客户端的app.config和服务器端的web.config。

    客户端app.config(下划线为修改的地方):

    <system.serviceModel>
      <bindings>
        <basicHttpBinding>
          <binding name="BasicHttpBinding_IAAASvc" 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="65536" maxArrayLength="16384"
                maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            <security mode="None">
              <transport clientCredentialType="None" proxyCredentialType="None"
                  realm="" />
              <message clientCredentialType="UserName" algorithmSuite="Default" />
            </security>
          </binding>
        </basicHttpBinding>
      </bindings>
      <client>
        <endpoint address="http://localhost:604/AAASvc.svc" binding="basicHttpBinding"
            bindingConfiguration="BasicHttpBinding_IAAASvc" contract="ServiceReference.IQuotSvc"
            name="BasicHttpBinding_IAAASvc" />
      </client>
    </system.serviceModel>

    服务器端的web.config:

    <system.serviceModel>
      <bindings>
        <basicHttpBinding>
          <binding name="Custom_Binding_A" maxBufferSize="65536" maxReceivedMessageSize="65536">
            <readerQuotas maxDepth="32" maxStringContentLength="65536" maxArrayLength="16384"
                          maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            <security mode="None"></security>
          </binding>
        </basicHttpBinding>
      </bindings>
      
      <behaviors>
        <serviceBehaviors>
          <behavior name="Custome_Beha_A">
            <serviceMetadata httpGetEnabled="true" />
            <serviceDebug includeExceptionDetailInFaults="true" />
            <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
          </behavior>
        </serviceBehaviors>
      </behaviors>
    
      <services>
        <service behaviorConfiguration="Custome_Beha_A" name="Eprinter.Quotation.Web.AAASvc">
          <endpoint address="" bindingConfiguration="Custom_Binding_A" binding="basicHttpBinding" contract="Eprinter.Quotation.Web.IAAASvc"/>
        </service>
      </services>

    这里需要另外增加Binding和behavior, 以及service的配置。需要注意的是,service配置里面,上面的name是名称空间.类名,下面的contract为名称空间.接口名。

  • 相关阅读:
    selenium 操作过程中,元素标红高亮的两种实现方式
    python pytest测试框架介绍五---日志实时输出
    pytest 3.9在python 2.7下的一个bug
    Qt assis tant 帮助集合文档 -由.qhcp生成.qhc
    Qt assistant .qch显示乱码问题
    qhelpgenerator 由qhp生成qch过程碰到的问题 记录
    Qt creator新建widget项目....no valid kits found.....
    Qt creator 账号
    Qt 写Excel
    Qt获取主窗口
  • 原文地址:https://www.cnblogs.com/icyJ/p/maxstringcontentlength.html
Copyright © 2011-2022 走看看