
我在控制台应用程序中添加了WCF服务引用,并尝试调用服务操作,得到了QuotaExceededException。我已经为这个问题寻找了解决方案,但我发现我需要更改绑定最大长度。但这对我来说是不可能的,我不应该改变服务配置。
异常消息:
已超过传入邮件(65536)的最大邮件大小配额。若要增加配额,请在适当的绑定元素上使用MaxReceivedMessageSize属性。

下面的是堆栈跟踪:
Server stack trace:
at System.ServiceModel.Channels.HttpInput.ThrowMaxReceivedMessageSizeExceeded()
at System.ServiceModel.Channels.HttpInput.GetMessageBuffer()
at System.ServiceModel.Channels.HttpInput.ReadBufferedMessage(Stream inputStream)
at System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(HttpRequestMessage httpRequestMessage, Exception& requestException)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at ConsoleApp2.ComponentService.IComponentService.GetPageConfiguration(String pageName, String roleCode, String processName, String wizardPageConfigGUID)
at ConsoleApp2.ComponentService.ComponentServiceClient.GetPageConfiguration(String pageName, String roleCode, String processName, String wizardPageConfigGUID) in D:\Work\tempABC\local\ConsoleApp2\ConsoleApp2\Connected Services\ComponentService\Reference.cs:line 5684
at ConsoleApp2.Program.Main(String[] args) in D:\Work\tempABC\local\ConsoleApp2\ConsoleApp2\Program.cs:line 13这是我的Config文件内容:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="ABC.EUV.Component.Service.Contract.IComponentService">
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://hyddmosrvi01.vertafore.com/XYZ/WebServices/ComponentService/ComponentService.svc"
binding="wsHttpBinding" bindingConfiguration="ABC.EUV.Component.Service.Contract.IComponentService"
contract="ComponentService.IComponentService" name="ABC.EUV.Component.Service.Contract.IComponentService" />
</client>
</system.serviceModel>
</configuration>发布于 2020-02-04 07:36:46
您需要在配置中增加邮件大小配额,如下所示:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="ABC.EUV.Component.Service.Contract.IComponentService" maxReceivedMessageSize="200000000" maxBufferSize="200000000" maxBufferPoolSize="200000000">
<readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://hyddmosrvi01.vertafore.com/XYZ/WebServices/ComponentService/ComponentService.svc"
binding="wsHttpBinding" bindingConfiguration="ABC.EUV.Component.Service.Contract.IComponentService"
contract="ComponentService.IComponentService" name="ABC.EUV.Component.Service.Contract.IComponentService" />
</client>
</system.serviceModel>
</configuration>https://stackoverflow.com/questions/60052367
复制相似问题