无法使用服务引用调用 WCF 服务操作
Unable to call WCF service Operation using service reference
我已将 WCF 服务引用添加到控制台应用程序并尝试调用服务操作,但出现 QuotaExceededException。
我为此搜索了解决方案,但发现我需要更改绑定最大长度。但是 me.I 不应该更改服务配置是不可能的。
异常消息:
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.
下面是堆栈跟踪:
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>
您需要增加邮件大小配额,配置如下:
<?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>
异常消息:
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.
下面是堆栈跟踪:
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>
您需要增加邮件大小配额,配置如下:
<?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>