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

  • 相关阅读:
    Struts2-Spring和Hibernate整合
    windows下使用Eclipse编译执行MapReduce程序 Hadoop2.6.0/Ubuntu
    Android 基于Netty的消息推送方案之对象的传递(四)
    基于JQuery实现表单元素值的回写
    iOS 从UITableViewController中分离数据源
    navicat premium 的使用——navicat 连接MySQL数据库
    【甘道夫】Ubuntu14 server + Hadoop2.2.0环境下Sqoop1.99.3部署记录
    罗永浩和锤子手机:对不起,我被你打动了
    用C语言解决迷宫问题
    Android利用reative_layout生成梅花界面
  • 原文地址:https://www.cnblogs.com/icyJ/p/maxstringcontentlength.html
Copyright © 2011-2022 走看看