Web services

AX 2012: Integrate Dynamics AX with Website

Posted on Updated on



What if you need to integrate a Retail E-Commerce website with the powerful Dynamics AX ERP at backend to leverage numerous functional capabilities it offers in the areas like but not limited to Supply Chain Management. Then you are reading the right blog post! We can achieve it through exposing custom AIF services as web services on IIS using enhanced inbound ports via HTTP adapter. In this post, we’ll expose customers data in Dynamics AX 2012 persisted in CustTable to an external interface using web services.

To simplify things, we’ll create a read service operation and then test our custom AIF service exposed as a web service using .Net console application. Although this blog post uses C# consumer to consume the custom service but the same service can be consumed by any website development platforms like ASP.NET and the possibilities are limitless!


1. Full compile revealing no errors.
2. Full CIL revealing no errors.
3. Install web services on IIS.
4. Configure default AIF website created while performing step 3.


1. Create contract class MAKCustTableContract.

  • Declare class variables for chosen fields of CustTable. Use same EDTs as used by table fields.
  • Create parm methods for each of the class variables.
  • Some of the parm methods are given below for reference.
  • To generate parm methods automatically, read this post.
class MAKCustTableContract
    CustAccount accountNum;
    CustBankAccountId bankAccount;
    CustCreditMaxMST creditMax;
    CustCreditRating creditRating;
    CustCurrencyCode currency;
    CustGroupId custGroup;
    CustDlvModeId dlvMode;
    DlvReasonId dlvReason;
    CustInvoiceAccount invoiceAccount;
    VendAccount vendAccount;
public CustAccount parmAccountNum(CustAccount _accountNum = accountNum)
    accountNum = _accountNum;

    return accountNum;

public CustBankAccountId parmBankAccount(CustBankAccountId _bankAccount = bankAccount)
    bankAccount = _bankAccount;

    return bankAccount;

3. Create service class MAKCustTableService.

  • Add readCustTable() method.
class MAKCustTableService
public List readCustTable()
    MAKCustTableContract    contract;
    List                    custlist = new List(Types::Class);
    CustTable               custTable;

    while select custTable
        where custTable.CustGroup == '20'
        contract = new MAKCustTableContract();

    return custList;

4. Create new service MAKCustTableService.

  • Create a new service node under AOT > Services.


  • Expand service node just created.
  • Right click on Operations to add new service operation and select the class method readCustTable.


  • Right click MAKCustTableService > Add-Ins > Register service.
  • Make sure it shows NoError in the status.


4. Create enhanced inbound port MAKCustTableServices.

  • Open Functional workspace.
  • Click System administration>Setup>Services and Application Integration Framework>Inbound ports.
  • Click New to create new inbound port.
  • Select HTTP for the adapter.
  • Select default AIF website in the URI.


  • Select Service operations from the Service contract customizations fast tab.


  • Activate the enhanced inbound port.


5. Test the URI address of the enhanced inbound port in the browser to ensure the service is activated.


5. Test the AIF custom service with C# consumer in .Net console application.

  • Open Visual Studio 2010.
  • Create new .Net console application project in C#.
  • Add new Service reference in the project Service References.
  • Give the URI of the enhanced inbound port we created in address.


  • Give the Program definition as follows:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MAKServiceConsumer
    using MAKCustTableServices;

    class Program
        static void Main(string[] args)
            CallContext context;
            MAKCustTableServiceClient client;
            List list;

            context = new CallContext();
            context.Company = "CEU";

            client = new MAKCustTableServiceClient();
            list = client.readCustTable(context).ToList();
  • Debug the program to see the web service returning data 🙂