gpt4 book ai didi

未从配置中读取 WCF maxReceivedMessageSize

转载 作者:行者123 更新时间:2023-12-03 01:54:01 25 4
gpt4 key购买 nike

我有以下用于 WCF 服务的服务器端 app.config:

  <system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="default" maxReceivedMessageSize="5000000">
<readerQuotas maxStringContentLength="5000000" maxArrayLength="5000000" />
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="Core.TOAService.Service1Behavior"
name="Core.TOAService.TOAService">
<endpoint address="" binding="wsHttpBinding" contract="Core.TOAService.ITOAService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/Core.TOAService/TOAService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Core.TOAService.Service1Behavior">
<!-- 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>

当我尝试向此服务传递一个较大的文件(仅约 250KB)时,我在 svclog 文件中记录了一个异常:

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.

正如您从配置顶部的绑定(bind)部分看到的,我尝试将 maxReceivedMessageSize 设置为 5000000,但服务仍然认为它设置为默认的 65536。关于什么是错误或哪个是错误的任何想法“适当的”绑定(bind)元素?

最佳答案

还有更多设置:-) 尝试 <binding> 上的“maxBufferPoolSize”和“maxBufferSize”标签。

但最大的问题是:您的端点没有引用该绑定(bind)配置!

<endpoint address="" 
binding="wsHttpBinding" contract="Core.TOAService.ITOAService">

您需要添加对它的引用,以便它变得有用 - 仅仅将其称为“默认”是行不通的......

<endpoint address="" 
binding="wsHttpBinding"
bindingConfiguration="default"
contract="Core.TOAService.ITOAService">

您领先于时代;-) 在 WCF 4(与 .NET 4.0 一起 - 2009 年晚些时候的某个时候)中,您将能够定义“默认绑定(bind)配置”,而无需显式命名和引用它们 -但现在,您需要在端点及其绑定(bind)以及您拥有的任何绑定(bind)(或行为)配置之间创建链接!

马克

关于未从配置中读取 WCF maxReceivedMessageSize,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1343628/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com