Search code examples
wcf

Unable to call WCF service Operation using service reference


enter image description hereI have added WCF service reference to console application and trying to call service operation,I got QuotaExceededException. I have searched for solution for this but i found i need to change binding maxlength. But it is not possible for me.I should not change service configuration.

Exception Message :

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.

enter image description here

Below Is the stack Trace:

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

This is my Config file Content :

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

Solution

  • You need to increase the message size quotas, in the config as following:

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