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为名称空间.接口名。

  • 相关阅读:
    函数式对象
    PageRank网页排名算法
    文档倒排序索引
    单词共现算法
    MapReduce关系代数运算
    矩阵乘法的MapReduce实现
    对象序列化(二)
    信息流产品和内容推荐算法
    从企业实操的角度谈深度学习(图像方向)的底层逻辑之概念普及
    Python深度学习企业实战之TensorFlow的底层原理及安装
  • 原文地址:https://www.cnblogs.com/icyJ/p/maxstringcontentlength.html
Copyright © 2011-2022 走看看