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: https://msdn.microsoft.com/en-us/library/ms733135.aspx

Blog: https://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" ?>

<configuration>

    <system.serviceModel>

        <bindings>

            <basicHttpBinding>

                <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"

                    useDefaultWebProxy="true">

                    <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" />

                    </security>

                </binding>

            </basicHttpBinding>

        </bindings>

        <client>

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

                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_FreeTextInvoiceService"

                contract="FreeTxtInvoiceWebService.FreeTextInvoiceService"

                name="BasicHttpBinding_FreeTextInvoiceService" />

        </client>

    </system.serviceModel>

</configuration>

These are the relevant binding sections of web.config:

<system.serviceModel>

    <bindings>

      <basicHttpBinding>

        <binding name="basicHttpBindingWindowsAuth"

          maxBufferSize="565536"

          maxReceivedMessageSize="565536">

          <security mode="TransportCredentialOnly">

            <transport clientCredentialType="Windows" />

          </security>

        </binding>

      </basicHttpBinding>

    </bindings>

<service behaviorConfiguration="serviceBehaviorConfiguration"

        name="Microsoft.Dynamics.IntegrationFramework.Service.FreeTextInvoiceService">

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

          bindingNamespace="https://schemas.microsoft.com/dynamics/2008/01/services"

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

      </service>

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: https://msdn.microsoft.com/en-us/library/ms731913.aspx

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

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

MSDN Blog: https://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

  • Anonymous
    April 30, 2009
    PingBack from http://asp-net-hosting.simplynetdev.com/web-service-message-limits-in-ax-2009/
  • Anonymous
    October 10, 2010
    Hi,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 isGeneration WCF configuration file.Cannot open the configuration file.Error in generationI have checked the user permission are all fine. Is there anything that we need to do to get this working?ThanksNavid
  • Anonymous
    October 13, 2010
    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.Dianne