首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用服务引用调用WCF服务操作

无法使用服务引用调用WCF服务操作
EN

Stack Overflow用户
提问于 2020-02-04 07:17:36
回答 1查看 87关注 0票数 0

我在控制台应用程序中添加了WCF服务引用,并尝试调用服务操作,得到了QuotaExceededException。我已经为这个问题寻找了解决方案,但我发现我需要更改绑定最大长度。但这对我来说是不可能的,我不应该改变服务配置。

异常消息:

已超过传入邮件(65536)的最大邮件大小配额。若要增加配额,请在适当的绑定元素上使用MaxReceivedMessageSize属性。

下面的是堆栈跟踪:

代码语言:javascript
复制
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文件内容:

代码语言:javascript
复制
<?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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-02-04 07:36:46

您需要在配置中增加邮件大小配额,如下所示:

代码语言:javascript
复制
<?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>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60052367

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档