I want to set the maxReceivedMessageSize in the App.config of the WCF Client.
If the maxReceivedMessageSize equals or is smaller then 4215 it works fine. Though when setting it to 4216 or any value above it, the default value of 65536 is taken.
My Client Code
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IConexaApiServic" maxReceivedMessageSize="4216" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://svsr02.conexa.local/HelloService/ConexaApiService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IConexaApiServic"
contract="ConexaApiService.IConexaApiService" name="BasicHttpBinding_IConexaApiService" />
</client>
</system.serviceModel>
</configuration>
And The relavant Server Code
<basicHttpBinding>
<binding name="BasicHttpEndpoint_MPSAPIServic" maxReceivedMessageSize="2000000">
<security mode="TransportWithMessageCredential" />
</binding>
<binding name="BasicHttpEndpoint_HelloService" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2000000">
</binding>
</basicHttpBinding>
<service name="IIS_test123.HelloService">
<endpoint address="ConexaApi" binding="basicHttpBinding" bindingConfiguration="BasicHttpEndpoint_HelloService" contract="IIS_test123.IHelloService"></endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/API/ConexaApiService" />
</baseAddresses>
</host>
</service>
</services>
Any idea how to fix this?
MaxReceivedMessageSize = 1000000; The value of this property can also be set in the configuration file.
By default, it is 65536.
This can be explainned. If you look at your exceptions:
And 4215 must be the size of your message if you consider that the exception does not raise if you increase it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With