Error MaxReceivedMessageSize in WCF

As new to WCF, please help me. I get this error. I searched the Internet for this problem and I have many solutions, but when I applied these solutions. some new problems that i am facing. So please provide me a valid solution.

Exceeded maximum message size quota for incoming messages (65536). To increase the quota, use the MaxReceivedMessageSize property in the corresponding binding element.

Web.config service file.

<system.serviceModel> <bindings> <basicHttpBinding> <binding name="WSHttpBinding_IService1" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> </binding> </basicHttpBinding> </bindings> <services> <service name="WcfServiceZone_Store.Service1" behaviorConfiguration="metadataBehavior"> <!-- Service Endpoints --> <endpoint address="" binding="wsHttpBinding" contract="WcfServiceZone_Store.IService1"> <identity> <dns value="localhost"/> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> <behaviors> <serviceBehaviors> <behavior name="metadataBehavior"> <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> <serviceMetadata httpGetEnabled="true"/> <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> 

Web.config client file:

 <system.serviceModel> <bindings> <basicHttpBinding> <binding name="WSHttpBinding_IService1" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="http://localhost:50274/Service1.svc" binding="wsHttpBinding" contract="ServiceReference1.IService1"> <identity> <dns value="localhost" /> </identity> </endpoint> </client> 

please tell me which side I need to make changes.

+4
source share
1 answer

You need to make changes on both sides - the server and the client, but you need to bind to the corresponding binding - the one that your service (and the client) actually uses!

So, in your case, on your server service, the service is configured to use wsHttpBinding :

 <service name="WcfServiceZone_Store.Service1" behaviorConfiguration="metadataBehavior"> <endpoint address="" binding="wsHttpBinding" contract="WcfServiceZone_Store.IService1"> ************* 

but you defined higher values ​​on basicHttpBinding ..... that won't work of course!

 <bindings> <basicHttpBinding> **************** this doesn't match with the defined binding on your endpoint! 

And you also do not refer to the new binding configuration that you defined - you need TELL WCF to use these new binding values!

So you need to do this on the server:

 <system.serviceModel> <bindings> <wsHttpBinding> <binding name="BindingWithMaxSizeIncreased" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> </binding> </wsHttpBinding> </bindings> <services> <service name="WcfServiceZone_Store.Service1" behaviorConfiguration="metadataBehavior"> <!-- Service Endpoints --> <endpoint address="" binding="wsHttpBinding" bindingConfiguration="BindingWithMaxSizeIncreased" -- use those new values! contract="WcfServiceZone_Store.IService1"> <identity> <dns value="localhost"/> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> 

The same on the client side:

  • define binding parameters for proper binding ( wsHttpBinding - not basicHttpBinding )
  • add a link to bindingConfiguration in the <endpoint> so that these values ​​are actually used
+3
source

Source: https://habr.com/ru/post/1502547/


All Articles