How to fix the MaxReceivedMessageSize error while using an AX2012 AIF service
The error message:
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.
What is the cause?
When you setup your AIF Service in AX2012 (basically a WCF service), you can also define an property called MaxReceivedMessageSize for your binding. The problem is, the MaxReceivedMessageSize defines the message size per direction. So you have to setup the message size on your client as well. If you request a message from the server, an the response is larger than your message size defined on your client.
The same goes for the other way around.
To find the WCF configuration for your AIF service in AX, just open the “System administration” in your client, got to “Setup”, “Application Framwork and Services” and then open the type of port you want to use.
You have to “Deactivate” the service before you can hit “Configure”.
If you have installed the SvcConfigEditor check the value under “Bindings” and your binding configuration.
To check your service from a client, just open the WCF test client (WcfTestClient)
Enter the service url from the Dynamics AX AIF configuration, then open the config file and select “Edit with SvcCofnigEditor”.
Now you can set the MaxReceivedMessageSize value to a higher value.
If you have integrated your service into an application, like a C# command line program, just take a look at your “app.config” or check the MaxReceivedMessageSize property from, for example, the System.ServiceModel.NetTcpBinding class.