传入消息的最大消息大小配额 (65536) 已超过 WCF
The maximum message size quota for incoming messages (65536) has been exceeded WCF
<?xml version="1.0"?>
<configuration>
<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 name ="SaadiqinWcf.SaadiqinServiceBehavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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"/>
<dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name ="jsonBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<services>
<service name="SaadiqinWcf.SaadiqinService" behaviorConfiguration="SaadiqinWcf.SaadiqinServiceBehavior">
<endpoint name ="SaadiqinEndPoint" address="**" binding="basicHttpBinding" bindingConfiguration="myBindingConfiguration" contract="**" />
<!-- <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>-->
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="myBindingConfiguration" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="01:50:00" openTimeout="01:50:00" sendTimeout="01:50:00" receiveTimeout="01:50:00">
<readerQuotas maxDepth="128" maxStringContentLength="8388608"
maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<httpProtocol>
<customHeaders>
<add name ="Access-Control-Allow-Origin" value ="*"/>
</customHeaders>
</httpProtocol>
<directoryBrowse enabled="true"/>
</system.webServer>
<connectionStrings>
<add name="SaadiqinEntities" connectionString="data source=*****,***;initial catalog=***;persist security info=true;user id=***; Password=***; TrustServerCertificate=True; multipleactiveresultsets=True;application name=EntityFramework" />
</connectionStrings>
</configuration>
这是我的 Web.config
文件。 运行 测试客户端时,我在 WCF 中遇到错误。我也添加了绑定配置,但它仍然抛出相同的错误(The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.)
。
我已经将 web.config
中的 MaxReceivedMessageSize
属性 设置为较大的值,我还使用上述配置将客户端本身代码中的绑定设置为服务很好,但没有变化。
绑定是否正确?我需要添加其他东西还是需要删除一些东西。我很困惑。
注意:我正在测试来自 WCF 测试客户端的服务。
我找到了答案。
实际上 WCF 测试客户端有自己的配置。我更改了配置文件。现在工作起来很有魅力。 :)
谢谢
<?xml version="1.0"?>
<configuration>
<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 name ="SaadiqinWcf.SaadiqinServiceBehavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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"/>
<dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name ="jsonBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<services>
<service name="SaadiqinWcf.SaadiqinService" behaviorConfiguration="SaadiqinWcf.SaadiqinServiceBehavior">
<endpoint name ="SaadiqinEndPoint" address="**" binding="basicHttpBinding" bindingConfiguration="myBindingConfiguration" contract="**" />
<!-- <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>-->
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="myBindingConfiguration" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="01:50:00" openTimeout="01:50:00" sendTimeout="01:50:00" receiveTimeout="01:50:00">
<readerQuotas maxDepth="128" maxStringContentLength="8388608"
maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<httpProtocol>
<customHeaders>
<add name ="Access-Control-Allow-Origin" value ="*"/>
</customHeaders>
</httpProtocol>
<directoryBrowse enabled="true"/>
</system.webServer>
<connectionStrings>
<add name="SaadiqinEntities" connectionString="data source=*****,***;initial catalog=***;persist security info=true;user id=***; Password=***; TrustServerCertificate=True; multipleactiveresultsets=True;application name=EntityFramework" />
</connectionStrings>
</configuration>
这是我的 Web.config
文件。 运行 测试客户端时,我在 WCF 中遇到错误。我也添加了绑定配置,但它仍然抛出相同的错误(The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.)
。
我已经将 web.config
中的 MaxReceivedMessageSize
属性 设置为较大的值,我还使用上述配置将客户端本身代码中的绑定设置为服务很好,但没有变化。
绑定是否正确?我需要添加其他东西还是需要删除一些东西。我很困惑。
注意:我正在测试来自 WCF 测试客户端的服务。
我找到了答案。 实际上 WCF 测试客户端有自己的配置。我更改了配置文件。现在工作起来很有魅力。 :)
谢谢