WCF已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性

 <?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="connStr" connectionString=""/>
</connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<!--<behavior>
--><!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false --><!--
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
--><!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 --><!--
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>-->
<behavior name="MyBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service behaviorConfiguration="MyBehavior" name="WcfService.Service1">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"
contract="WcfService.IService1" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="NewBinding0"
closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
maxBufferSize="" maxBufferPoolSize="" maxReceivedMessageSize=""
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="" maxStringContentLength="" maxArrayLength="" maxBytesPerRead="" maxNameTableCharCount=""/>
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings> </system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
若要在调试过程中浏览 Web 应用程序根目录,请将下面的值设置为 True。
在部署之前将该值设置为 False 可避免泄露 Web 应用程序文件夹信息。
-->
<directoryBrowse enabled="true"/>
</system.webServer> </configuration>

服务器Web.config

 <?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
</configSections>
<connectionStrings> </connectionStrings>
<appSettings> </appSettings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" maxBufferSize="" maxReceivedMessageSize="" /> </basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:16583/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceData.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel> </configuration>

客户端App.config

客户端调用的时候加上这一段代码即可:

ServiceData.Service1Client client = new ServiceData.Service1Client();
(client.Endpoint.Binding as BasicHttpBinding).MaxReceivedMessageSize = int.MaxValue;
(client.Endpoint.Binding as BasicHttpBinding).MaxBufferPoolSize = int.MaxValue;
(client.Endpoint.Binding as BasicHttpBinding).MaxBufferSize = int.MaxValue;

上一篇:mysql中外键的特点


下一篇:C和指针 第四章 习题