Web Service Message Limits in AX 2009

By default, the WCF values for maxBufferSize and maxReceivedMessageSize are both 65536 (64K). If you send a request to a document service in Microsoft Dynamics AX and the message size exceeds this value, you’ll see a cryptic error that says something like: “The remote server returned an error: (400) Bad  Request.” You may also see an error message that references the maxReceivedMessageSize property.


To fix this problem, increase the binding properties maxBufferSize and maxReceivedMessageSize.  These properties are part of the <bindings> section in the app.config and web.config. Both parameters must be changed on the both the client side in the app.config and on the server side in the web.config. To change these properties, you can edit the config files directly or go to Basic Setup > AIF > Services and click the Configure button to open the service configuration editor. Here are some links that cover this aspect of WCF:


MSDN: http://msdn.microsoft.com/en-us/library/ms733135.aspx

Blog: http://geekswithblogs.net/niemguy/archive/2007/12/11/wcf-maxstringcontentlength-maxbuffersize-and-maxreceivedmessagesize.aspx


These are the relevant binding sections of app.config:

<?xml version="1.0" encoding="utf-8" ?>





                <binding name="BasicHttpBinding_FreeTextInvoiceService" closeTimeout="00:01:00"

                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"

                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"

                    maxBufferSize="565536" maxBufferPoolSize="524288" maxReceivedMessageSize="565536"

                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"


                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"

                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />

                    <security mode="TransportCredentialOnly">

                        <transport clientCredentialType="Windows" proxyCredentialType="None"

                            realm="" />

                        <message clientCredentialType="UserName" algorithmSuite="Default" />






            <endpoint address="http://dynamicsvm.contoso.com/MicrosoftDynamicsAXAif50/freetextinvoiceservice.svc"

                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_FreeTextInvoiceService"


                name="BasicHttpBinding_FreeTextInvoiceService" />





These are the relevant binding sections of web.config:




        <binding name="basicHttpBindingWindowsAuth"



          <security mode="TransportCredentialOnly">

            <transport clientCredentialType="Windows" />






<service behaviorConfiguration="serviceBehaviorConfiguration"


        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBindingWindowsAuth"


          contract="Microsoft.Dynamics.IntegrationFramework.Service.FreeTextInvoiceService" />



In addition to changing these properties, you might also want to look at the transportMode property if your messages are very large. By default, this property is set to Buffered for the document services in AX. More relevant links about this property are:


MSDN: http://msdn.microsoft.com/en-us/library/ms731913.aspx

MSDN: http://msdn.microsoft.com/en-us/library/ms789010.aspx


MSDN Forum: http://social.msdn.microsoft.com/forums/en-US/wcf/thread/f00037f1-02e1-4e1c-b6ed-03fe134f3460/

MSDN Blog: http://blogs.msdn.com/drnick/archive/2006/03/31/565558.aspx


There are many considerations when it comes to message size and services such as limits in IIS, WCF configuration options, etc. Let me know if this resolves your message size issues or if you come across any other tips that worked in your particular installation.

Comments (3)

  1. Navid says:


    Thank you for the brilliant post. We are facing the same problem. But when we try to change the configuration and re-generate the artifacts using the services form in AX we get an error. the error part from the infolog window is

    Generation WCF configuration file.

    Cannot open the configuration file.

    Error in generation

    I have checked the user permission are all fine. Is there anything that we need to do to get this working?



  2. Dianne says:

    I don't know what is causing that error. For more help, you can try posting to the forums at community.dynamics.com/…/33.aspx.


Skip to main content