中午测试员在测试系统模块时发现无法通过WCF从服务器下载数据,检查配置文件后,建议开发人员修改站点的WEB.CONFIG文件,具体修改对比如下:

旧的:

<binding name="BasicHttpBinding_ICentaMiddleService" 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="8192" maxArrayLength="16384"

maxBytesPerRead="4096" maxNameTableCharCount="16384" />

<security mode="None">

<transport clientCredentialType="None" proxyCredentialType="None"

realm="" />

<message clientCredentialType="UserName" algorithmSuite="Default" />

</security>

</binding>

新的:

<binding name="BasicHttpBinding_ICentaMiddleService" 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="9223372036854775807"

messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed"

useDefaultWebProxy="true">

<readerQuotas maxDepth="6553500" maxStringContentLength="2147483647"

maxArrayLength="6553500" maxBytesPerRead="6553500" maxNameTableCharCount="6553500" />

<security mode="None">

<transport clientCredentialType="None" proxyCredentialType="None"

realm="" />

<message clientCredentialType="UserName" algorithmSuite="Default" />

</security>

</binding>

注意这里修改的主要是maxReceivedMessageSize这个属性,解决了从服务器通过WCF下载大容量数据的问题。

下午测试人员继续测试,发现无法将数据通过WCF保存回服务器端。检查数据后发现,需要被保存的数据超过9K,而WCF服务器端使用的是binding="basicHttpBinding"这个数据绑定方式。思路打开,则应该是由于服务器端的接收的数据大小有限制。

当初次引用服务后,显示的服务器端binding="basicHttpBinding" 的最大上传数据容量是:

<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"

maxBytesPerRead="4096" maxNameTableCharCount="16384" />

注意是maxStringContentLength="8192" ,那么判定,是由于绑定的默认值未被修改的缘故。接着修改服务器端的web.config配置文件。修改对比如下:

旧的:

<system.serviceModel>

<behaviors>

<serviceBehaviors>

<behavior name="CVMTransactionCaseServiceBehavior">

<serviceMetadata httpGetEnabled="true" />

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="AuthTaxTransactionInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="DealingTransactionInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="HousePassTransactionInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="PreAuthTransactionInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="PropertyApplyInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="CommonInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true" />

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="CenterAssignServiceBehavior">

<serviceMetadata httpGetEnabled="true" />

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

</serviceBehaviors>

</behaviors>

<services>

<service name="CentaLine.CVM.Services.CVMTransactionCaseService" behaviorConfiguration="CVMTransactionCaseServiceBehavior">

<endpoint address="" binding="basicHttpBinding" contract="CentaLine.CVM.Services.ICVMTransactionCaseService" />

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

</service>

<service name="CentaLine.CVM.Services.AuthTaxTransactionInfoService" behaviorConfiguration="AuthTaxTransactionInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" contract="CentaLine.CVM.Services.IAuthTaxTransactionInfoService"/>

</service>

<service name="CentaLine.CVM.Services.DealingTransactionInfoService" behaviorConfiguration="DealingTransactionInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" contract="CentaLine.CVM.Services.IDealingTransactionInfoService"/>

</service>

<service name="CentaLine.CVM.Services.HousePassTransactionInfoService" behaviorConfiguration="HousePassTransactionInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" contract="CentaLine.CVM.Services.IHousePassTransactionInfoService"/>

</service>

<service name="CentaLine.CVM.Services.PreAuthTransactionInfoService" behaviorConfiguration="PreAuthTransactionInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" contract="CentaLine.CVM.Services.IPreAuthTransactionInfoService"/>

</service>

<service name="CentaLine.CVM.Services.PropertyApplyInfoService" behaviorConfiguration="PropertyApplyInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" contract="CentaLine.CVM.Services.IPropertyApplyInfoService"/>

</service>

<service name="CentaLine.CVM.Services.CommonInfoService" behaviorConfiguration="CommonInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" contract="CentaLine.CVM.Services.ICommonInfoService"/>

</service>

<service name="CentaLine.CVM.Services.CenterAssignService" behaviorConfiguration="CenterAssignServiceBehavior">

<endpoint address="" binding="basicHttpBinding" contract="CentaLine.CVM.Services.ICenterAssignService"/>

</service>

</services>

</system.serviceModel>

新的:

<system.serviceModel>

<!--<behaviors />-->

<bindings>

<basicHttpBinding>

<binding name="NewBinding0" maxReceivedMessageSize="6553600">

<readerQuotas maxStringContentLength="6553600" />

</binding>

</basicHttpBinding>

</bindings>

<behaviors>

<serviceBehaviors>

<behavior name="CVMTransactionCaseServiceBehavior">

<serviceMetadata httpGetEnabled="true" />

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="AuthTaxTransactionInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="DealingTransactionInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="HousePassTransactionInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="PreAuthTransactionInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="PropertyApplyInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="CommonInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true" />

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="CenterAssignServiceBehavior">

<serviceMetadata httpGetEnabled="true" />

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

</serviceBehaviors>

</behaviors>

<services>

<service name="CentaLine.CVM.Services.CVMTransactionCaseService"behaviorConfiguration="CVMTransactionCaseServiceBehavior">

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"contract="CentaLine.CVM.Services.ICVMTransactionCaseService" />

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

</service>

<service name="CentaLine.CVM.Services.AuthTaxTransactionInfoService"behaviorConfiguration="AuthTaxTransactionInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"contract="CentaLine.CVM.Services.IAuthTaxTransactionInfoService"/>

</service>

<service name="CentaLine.CVM.Services.DealingTransactionInfoService"behaviorConfiguration="DealingTransactionInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"contract="CentaLine.CVM.Services.IDealingTransactionInfoService"/>

</service>

<service name="CentaLine.CVM.Services.HousePassTransactionInfoService"behaviorConfiguration="HousePassTransactionInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"contract="CentaLine.CVM.Services.IHousePassTransactionInfoService"/>

</service>

<!--<service name="CentaLine.CVM.Services.PreAuthTransactionInfoService" behaviorConfiguration="PreAuthTransactionInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" contract="CentaLine.CVM.Services.IPreAuthTransactionInfoService"/>

</service>-->

<service name="CentaLine.CVM.Services.PreAuthTransactionInfoService"behaviorConfiguration="PreAuthTransactionInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"

contract="CentaLine.CVM.Services.IPreAuthTransactionInfoService" />

<!--<host>

<baseAddresses>

<add baseAddress="net.tcp://localhost:8080/service" />

</baseAddresses>

</host>-->

</service>

<service name="CentaLine.CVM.Services.PropertyApplyInfoService"behaviorConfiguration="PropertyApplyInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"contract="CentaLine.CVM.Services.IPropertyApplyInfoService"/>

</service>

<service name="CentaLine.CVM.Services.CommonInfoService"behaviorConfiguration="CommonInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"contract="CentaLine.CVM.Services.ICommonInfoService"/>

</service>

<service name="CentaLine.CVM.Services.CenterAssignService"behaviorConfiguration="CenterAssignServiceBehavior">

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"contract="CentaLine.CVM.Services.ICenterAssignService"/>

</service>

</services>

</system.serviceModel>

主要添加内容:

<bindings>

          <basicHttpBinding>

              <binding name="NewBinding0" maxReceivedMessageSize="6553600">

                  <readerQuotas maxStringContentLength="6553600" />

              </binding>

          </basicHttpBinding>

</bindings>

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"

contract="CentaLine.CVM.Services.IPreAuthTransactionInfoService" />

最后单元测试,通过!爽!

WCF 配置文件中的MaxStringContentLength & MaxReceivedMessageSize的更多相关文章

  1. 在WCF程序中动态修改app.config配置文件

    今天在个WCF程序中加入了修改配置文件的功能.我是直接通过IO操作修改的app.config文件内容,修改后发现发现其并不生效,用Google搜了一下,在园子里的文章动态修改App.Config 和w ...

  2. WCF配置文件与文件下载之坎坷路

    题外话:本以为我会WCF了,精通WCF了,毕竟刚做过一个WCF的项目,不就是写写契约接口,然后实现接口,改下配置.最后用控制台或者服务发布一下,不就能用了.不就是简单ABC吗?不是So Easy吗?做 ...

  3. [转]使用代码去描述WCF配置文件

    转自:使用代码去描述WCF配置文件 在应用程序部署的时候,WCF客户端因为服务器地址的变化,需要修改程序配置文件的地址URL,手动修改很不方便,还会造成错误,所以尽量把描述WCF配置文件的配置使用代码 ...

  4. WCF 配置文件

    <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.S ...

  5. 使用WCF服务的客户端出现maxReceivedMessageSize异常

    使用WCF服务的客户端出现maxReceivedMessageSize异常解决方案 当使用WCF的客户端调取的数据过多时,会出现这个异常.一般情况下,系统默认值是65536,大约容纳100-200条左 ...

  6. WCF 配置文件(三)

    配置文件概述 WCF服务配置是WCF服务编程的主要部分.WCF作为分布式开发的基础框架,在定义服务以及定义消费服务的客户端时,都使用了配置文件的方法.虽然WCF也提供硬编程的方式,通过在代码中直接设置 ...

  7. WCF技术剖析之二十: 服务在WCF体系中是如何被描述的?

    原文:WCF技术剖析之二十: 服务在WCF体系中是如何被描述的? 任何一个程序都需要运行于一个确定的进程中,进程是一个容器,其中包含程序实例运行所需的资源.同理,一个WCF服务的监听与执行同样需要通过 ...

  8. 总结WCF开发中遇到的几个问题

    最近的项目,需要用到WCF,在以前的工作中,经常是将WCF托管在IIS中,主要有几下几个原因:      第一:部署非常方便,和部署一个站点没什么区别:      第二:不受防火墙的影响,因为一般服务 ...

  9. Entity Framework 6 Recipes 2nd Edition(9-7)译->在WCF服务中序列化代理

    9-7. 在WCF服务中序列化代理 问题 从一个查询里返回一个动态代理对象,想要把它序列为一个POCO(Plain-Old CLR Objects)对象. 实现基于POCO实体对象, 在运行时,EF会 ...

随机推荐

  1. 设置Echarts鼠标悬浮样式

    在option下 tooltip内添加以下代码: (本文在后台进行传值 也就是其中的viewstate[]) tooltip: { show: true, trigger: 'axis', //sho ...

  2. 6.12---esultMap查询所有

  3. 从React看weight开发

    从当前云发展的势头来看几乎所有互联网应用都趋向大一统的趋势,一个node下面加一堆应用,同时我们项目也趋向把复杂的大应用拆分成多个小应用,通过各种复杂的Api来协作,通信,达到同样的效果. 可以看出, ...

  4. 打开VMware Workstation,虚拟机不见了

    1 打开VM,发现虚拟机不见了 如图所示: 此时先别急着再次安装虚拟机. 2 先打开设备上所有已安装过的虚拟机,看你需要的还在不在 3 总结 如果打开后发现你要的虚拟机还存在,直接打开就好.否则,就得 ...

  5. Selenium常用方法及函数

    新建实例driver = webdriver.Chrome() 1.获取当前页面Url的函数方法:current_url实例:driver.current_url 2.表单的提交方法:submit解释 ...

  6. 华硕(ASUS)X554LP笔记本重装win7后网卡和USB驱动问题的解决

    以前在其它笔记本上采用U盘克隆安装winxp系统非常顺利,各种硬件驱动能自动识别并安装. 手上有一台别人的华硕(ASUS)X554LP笔记本,原装win8.1,用不惯,想装个win7旗舰版. 照例去系 ...

  7. C# datagrideview插件的使用

    private void btnLogin_Click(object sender, EventArgs e) { string txtUserName = this.txtUserName.Text ...

  8. Linux系统的启动流程

    Linux系统的启动流程: 1.通电(通常按下电源键,开始通电) 2.加载BIOS (通常看到显示器提示按F2进入主板) 3.读取MBR (MBR硬盘的入口地址,用来装载引导) 4.进入引导 (通常有 ...

  9. MySQL学习笔记(十二)__连接查询(一)

    连接查询含义:又称多表查询,当查询的字段来自多个表时,就会用到连接查询 笛卡尔乘积现象:表1 有 m 行,表2 有 n 行,结果 = m*n 行发生原因:没有有效的连接条件如何避免:添加有效的连接条件 ...

  10. 梦想Android版CAD控件2018.10.12更新

    下载地址: http://www.mxdraw.com/ndetail_10106.html 1. 增加读写对象扩展字典功能 2. 修改样条线显示错误 3. 修改shx文字显示错误 4. 增加向量运算 ...