I have a WCF web service which is hosted at a .svc file by ASP.NET. .svc file contains following configuration:
<%@ ServiceHost Language="C#" Debug="true" Service="assembly.IPriceListProvider, assembly" Factory="Autofac.Integration.Wcf.AutofacServiceHostFactory, Autofac.Integration.Wcf" %>
web.config contains configuration of the WCF. Here goes the binding configuration:
<binding name="basicHttpBinding_PriceListProvider" maxBufferSize="10485760"
maxReceivedMessageSize="10485760">
<readerQuotas maxArrayLength="16384000" />
</binding>
To test the service, I click on .svc file and click F5. WCF Test Client is opened. But the configuration has changed. The values which I've explicitly defined have now default values:
<binding name="basicHttpBindingEndPoint_PriceListProvider" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
**maxBufferSize="65536"** maxBufferPoolSize="524288" **maxReceivedMessageSize="65536"**
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" **maxArrayLength="16384"**
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
Why does the configuration change? How do I persist original values?
I've heard something about simplified .svc configuration: a default binding for .svc is configured even if you don't specify it explicitly in web.config. Can it be the case?
The values for maxBufferSize and maxReceivedMessageSize are not propagated to the WSDL file that is published by your service. That´s why the wcf test client is unable to retrieve them and takes default values.
You can still change the values with the SvcConfigEditor every time you start the wcf test client. Therefor perform a right click on the config file in the wcf test client and look for bindings. But the changes will be lost, the next time you start the client.
You can also test your service with a self written client and set the values there like shown in the following example.
BasicHttpBinding binding= new BasicHttpBinding();
binding.MaxRecievedMessageSize = yourValue;
EndpointAddress endpointAddress = new EndpointAddress("the address");
ClientForContract client= new ClientForContract (binding,endpointAddress);
client.TheMethod();
client.Close();
Hope this helps!