WCF客户端传输大数据到服务端失败配置问题

最近使用WCF遇到一个问题:当客户端向WCF服务发送一个大量数据时候,发现会提示:

"读取 XML 数据时,超出最大字符串内容长度配额 (8192)。通过更改在创建 XML 读取器时所使用的 XmlDictionaryReaderQuotas 对象的 MaxStringContentLength 属性,,可增加此配额。"于是上网搜索,都说修改配置就可以,但我是初学者,修改半天还没弄出来,最后各种整合,尝试,终于成功了,于是记下了,以备以后需要:

在配置文件内添加如下代码就可以了(只需要修改服务端配置文件):

1.在<system.serviceModel>节点下添加:

<bindings> <basicHttpBinding> <binding name="NewBinding0" closeTimeout="10:10:00" openTimeout="10:10:00" receiveTimeout="10:10:00" sendTimeout="10:10:00" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed" useDefaultWebProxy="true"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> <security mode="None"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> </basicHttpBinding> </bindings>

<services> <service behaviorConfiguration="NewBehavior0" name="WcfService.GXSC.LoginService"> <endpoint binding="basicHttpBinding" contract="WcfService.GXSC.ILoginService" /> <host> <baseAddresses> <add baseAddress=":1379/GXSC/LoginService.svc" /> </baseAddresses> </host> </service> <service behaviorConfiguration="NewBehavior0" name="WcfService.GXSC.ShipInfoService"> <endpoint binding="basicHttpBinding" contract="WcfService.GXSC.IShipInfoService" /> <host> <baseAddresses> <add baseAddress=":1379/GXSC/ShipInfoService.svc" /> </baseAddresses> </host> </service> </services>

2.<behaviors>下 <serviceBehaviors>节点下添加如下:

<behavior name="NewBehavior0"> <serviceMetadata httpGetEnabled="true" /> <dataContractSerializer maxItemsInObjectGraph="2147483647" /> <serviceThrottling maxConcurrentCalls="1000" maxConcurrentSessions="1000" maxConcurrentInstances="1000" /> <serviceDebug includeExceptionDetailInFaults="true" /> </behavior>

就ok了

拿望远镜看别人,拿放大镜看自己。

WCF客户端传输大数据到服务端失败配置问题

相关文章:

你感兴趣的文章:

标签云: