I feel I've been wrongfully confident that just as you do
Update Service Reference for a WCF Service in your client application, the latter picks up the latest values for things like
maxStringContentLength
from your contract's binding in
Web.config and updates its own binding details, so client & service can have agreeable data exchange as per the maximum string size that can be passed.
I have already killed numerous hours trying to comprehend why on earth this doesn't work, i.e. when we do the reference update on the client side it generates the wrong (default) values for all such binding properties. For example, it always creates
maxStringContentLength="8192"
:(
There are so many posts out there of people trying to make sense out of it, but nothing of good value.
Some suggest use of external configuration, which is no good, because my client needs to add reference and initiate correct binding remotely. Others suggest modification of the client side after adding the reference, which is overly stupid and doesn't work anyway. There are those who say that giving service full name or using unnamed binding configuration helped them, but it's all reading off coffee grounds, and gave me no result.
So how do we configure
Web.config on the WCF Service side to make sure its clients can automatically pick up the right binding parameters when adding or updating reference to the service?
Configuration snippet from the service's
Web.config:
<services>
<service name="MyService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:1234/"/>
</baseAddresses>
</host>
<endpoint address="MyService.svc" binding="basicHttpBinding" contract="MyNamespace.IMyService"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding sendTimeout="00:50:00" receiveTimeout="00:40:00">
<readerQuotas maxStringContentLength="100000"/>
</binding>
</basicHttpBinding>
</bindings>