我遇到了以下错误的问题:“已超出传入消息的最大消息大小配额 (65536)。要增加配额,请在适当的绑定元素上使用 MaxReceivedMessageSize 属性。 ”
所以我做了一些研究,发现我需要增加缓冲区和消息大小,这是我的 WCF 服务配置文件:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="default" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"/>
</wsHttpBinding>
</bindings>
<services>
<service name="WCF.Service.Service">
<endpoint address="ws" name="ws" bindingConfiguration="default" binding="wsHttpBinding" contract="WCF.Service.Contracts.IService" />
<endpoint address="mex" binding="mexHttpBinding" name="mex" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True" />
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
当我在 WCF 测试客户端中运行服务并查看生成的客户端配置文件时,它没有我的绑定:
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="ws" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:37444/Service.svc/ws" binding="wsHttpBinding"
bindingConfiguration="ws" contract="IService" name="ws">
<identity>
<userPrincipalName value="username@domain" />
</identity>
</endpoint>
</client>
</system.serviceModel>
我不知道为什么我的绑定配置没有被应用!?WCF 测试客户端也设置为始终重新生成配置。我还尝试在消费前端应用程序中更新服务引用,但它也没有获得更新的绑定配置。任何建议将不胜感激。谢谢!