Click here to Skip to main content
16,015,531 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Failed in WCF w/ the message:
HTML
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.

Then, using tha approach in https://www.youtube.com/watch?v=7ediHIeIWrM[^], I modified the config through the WCF Test Client's Editor, it works (see the config below).
XML
<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
       <!-- The binding block: added through the WCF Test Client Editor -->
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_ITransInfo" maxBufferPoolSize="2147483647"
                    maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
                <binding name="BasicHttpBinding_ITransInfoJson" maxBufferPoolSize="2147483647"
                    maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:35104/TransInfo.svc" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_ITransInfo" contract="ITransInfo"
                name="BasicHttpBinding_ITransInfo" />
            <endpoint address="http://localhost:35104/TransInfo.svc" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_ITransInfoJson" contract="ITransInfoJson"
                name="BasicHttpBinding_ITransInfoJson" />
        </client>
    <!-- The binding block added -->
    </system.serviceModel>
</configuration>

However, if I re-debug again, the Client.dll.config likes before, the default.config (the biding block is gone), which means the modified config was not saved actually. How can this problem be solved since I have to deploy it on my server? Or where is the default.config so I can modified it. Thanks.
*******
I also tried to dynamically setup the max. message size by the code below. But it does not work.
HTML
System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding("BasicHttpBinding_ITransInfo");
System.ServiceModel.BasicHttpBinding binding2 = new System.ServiceModel.BasicHttpBinding("BasicHttpBinding_ITransInfoJson");

binding.MaxBufferSize = 2147483647;
binding.MaxReceivedMessageSize= 2147483647;
binding.MaxBufferPoolSize = 2147483647;
binding2.MaxBufferSize = 2147483647;
binding2.MaxReceivedMessageSize = 2147483647;
binding2.MaxBufferPoolSize = 2147483647;
System.Xml.XmlDictionaryReaderQuotas myReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas();
myReaderQuotas.MaxStringContentLength = 2147483647;
myReaderQuotas.MaxNameTableCharCount = 2147483647;
myReaderQuotas.MaxArrayLength= 2147483647;
myReaderQuotas.MaxBytesPerRead= 2147483647;
myReaderQuotas.MaxDepth=64;
binding.GetType().GetProperty("ReaderQuotas").SetValue(binding, myReaderQuotas, null);
binding2.GetType().GetProperty("ReaderQuotas").SetValue(binding2, myReaderQuotas, null);
Posted
Updated 14-Dec-15 5:24am
v10
Comments
CHill60 14-Dec-15 8:53am    
Do you have the "Copy to Output Directory" property for the config file set to "Do not copy"?
s yu 14-Dec-15 9:07am    
No. how to do it? Please provide your advisory. Thanks.
s yu 14-Dec-15 14:27pm    
Problem solved by referring to https://msdn.microsoft.com/en-us/library/bb552364%28v=vs.110%29.aspx. The procedure is below:
1) In WCF Test Client, from Tools->Options->Client Configuration tab, check-offAlways Regenerate Config When Launching Services option.
2) Edit the configuration through the WCF test Client.
3) Save it.
Thanks for your review.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900