【问题标题】:Unable to call WCF service Operation using service reference无法使用服务引用调用 WCF 服务操作
【发布时间】:2020-12-15 17:20:19
【问题描述】:

我已将 WCF 服务引用添加到控制台应用程序并尝试调用服务操作,但出现 QuotaExceededException。 我已经为此寻找解决方案,但我发现我需要更改绑定 maxlength。但这对我来说是不可能的。我不应该更改服务配置。

异常信息:

传入邮件的最大邮件大小配额 (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

这是我的配置文件内容:

<?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>

【问题讨论】:

  • 添加绑定&lt;binding name="binding name.." maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"/&gt;到你的app.config
  • 我没有服务。它托管在不同的位置。所以我无法更改配置。
  • 当您将服务引用添加到您的项目时,服务客户端配置会自动包含在您的配置中。所以请分享你的 web.config。看看stackoverflow.com/questions/884235/…
  • 我已经发布了我的配置文件。谢谢

标签: wcf


【解决方案1】:

您需要增加消息大小配额,在配置中如下:

<?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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多