Creating a Custom Inbound AIF Service in Microsoft Dynamics AX 2012


Application Integration Framework (AIF) services are used to communicate with external systems or applications. Microsoft Dynamics AX 2012 has the following types of services:

  1. Document services
  2. Custom services
  3. System services

An AIF service can be Inbound or Outbound. An Inbound service is used when you want to send data to an external system and Outbound services are used when you want to retrieve data. This tutorial will guide you in creating Custom Inbound AIF services in Microsoft Dynamics AX 2012. Custom services are used when:

  1. The complexity of the entities is relatively low.
  2. When you want to have full control of the service contract.
  3. When data contracts needs to be shared with different entities.


  1. Microsoft Dynamics AX 2012
  2. AIF services must be installed and configured on IIS

Important Concepts

  1. Service operation

    Service operations are class methods that expose any business logic in a service. To define a service operation, add the SysEntryPointAttribute attribute at the top of a method. Any existing method can be converted to a service operation by adding this attribute at the beginning of the method.
    The service operation name cannot include Create, Find, Update or Delete. These names are reserved to be used by AIF Document services. AX will make an exception when they are called from a client.

  2. SysEntryPointAttribute

    SysEntryPointAttribute defines the authorization checks that will be performed when a method is called from the server. This attribute must be set on all the service operations. If the value is “true”, it means that authorization checks will be performed for all the tables accessed in the method and if set to “false”, no authorization checks will be performed.

  3. AifCollectionTypeAttribute

    AifCollectionTypeAttribute is used when you want to use a collection as a return type or in a parameter of a service operation. This attribute defines the type of data a collection contains.


As part of this tutorial the service will return the list of customer names in Dynamics AX.


  1. First we will create a new class which will contain Service operations.

  3. Open AOT. Go to Classes and create a new class. Let’s name it CustomerServiceDemo.

  5. Set the RunOn property of the class to Server. This will make sure the class always executes on the server.

  7. Add a new method and name it as getCustomerNameList. This method will query customers’ names and return a Type list string. Write the following code in the method:
  8. [SysEntryPointAttribute(true),
    AifCollectionTypeAttribute('return', Types::String)]
    //return denotes the parameter type and String specifies the type of data the collection will hold
    public List getCustomerNameList()
        CustTable       custTable;    
        List list = new List(Types::String);    
        //select all customers
        while select * from custTable        
            //add customer name in the list
        return list;
  9. The SysEntryPointAttribute tells AX that this method is a service operation method.

  11. Now we will create a new service and add the above created service operation to it.

  13. Go to Services, right click and select New Service.

  15. Name it as CustomerServiceDemo.

  17. Open the properties of the newly created service and select the CustomerServiceDemo class in the Class field.

  19. Now expand the CustomerServiceDemo service node and add a new Operation by right clicking on Operations and selecting Add Operation.

  21. All service operations present in the class will be listed. Select the getCustomerNameList service operation by checking the Add field in the grid and press OK.

  23. The next step is to create a service group and deploy the service to the Inbound Port.

  25. Go to Service Groups, right click and select New Service group.

  27. Name it as CustomerServiceDemoGroup.

  29. Set the AutoDeploy to Yes (Service will start automatically when AOS is started) and set the Description as Customer name service.

  31. Right click the newly created service group and select New Service Node Reference.

  33. In the newly created service node, set the Service property to CustomerServiceDemo. The Name property will automatically default to the Service name.

  35. Now right click the service group and select Deploy Service Group.

  37. A success message will appear if the service group is successfully deployed.

  39. To verify it, go to System administration à Setup à Services and Application Integration Framework à Inbound ports.

  41. The Service group name CustomerServiceDemoGroup will appear here as Port name with a green check mark. This shows that service group is deployed and active. If a red ‘x’ is appearing, select Activate from the action pane to activate the port.

  43. The WSDL URI is the URL of the service which can be used by external systems to access the service.

  45. To test whether the service is running properly, open the Visual Studio Command Prompt by going to All Programs à Microsoft Visual Studio 2010 à Visual Studio Tools à Visual Studio Command Prompt.

  47. Write wcftestclient and press enter. WCF Test Client will open.

  49. Now, go to File àAdd Service.

  51. In the Add Service dialog box, paste the WSDL URI of the port and press OK.

  53. The WCF Test Client will open the service with the list of operations available.

  55. Double click the getCustomerNameList. It will open the operation details in the right hand side pane.

  57. Click the Invoke button. The result of the service will appear in the Response pane.

  59. Pat yourself on the back. You are finished!
November 5, 2013
  • Kamalakannan Elangovan

    Neat one…Helpful for beginners

  • Glad you like it!

  • Won’t tell

    “An Inbound service is used when you want to send data to an external system and Outbound services are used when you want to retrieve data.” – vice versa

  • Naga Prasad

    hi im new to ax and my issue is as im trying with custTable the output was perfect but when i tried the same with my own table it does’nt show the records. so i compared with custTable it has methods like name then i tried with adding methods to my own table but still i face the same problem. would be thankful if u can provide process for userdefined tables (which methods should be added and code regarding that.) thanks in advance

  • Bachir Seck

    Hi. Thanks a lot for your nice post. I want to create a custom service that creates entities in AX 2012
    using a local XML file. This can be done by using Document service. But I
    need to customize the XML schema of the input file. In addition, I
    think that the custom services are easier to handle than document ones.

    So I created a serviceContract with the createEntity() operation and a
    dataContract implementing AifXMLSerializable interface. In the
    dataContract, I implemented the getSchema() method to specify the xsd of
    the input file. Then I created the service and the inbound port. And by
    using a C# Console Application we can invoke the service and create
    entity in AX. Now I wish to consume this service by using AX job. Can
    you tell me how I can proceed to do so.

    Thanks a lot.

  • Vinai Varghese

    Nice one. Thanks for the post.

  • rajesh

    Hi ,
    Shall we save the XML file in archive folder after successful execution through file system adapter in aif inbound?
    if possible will guide me how to do it?


  • Karthick.M

    Great article…

  • Karthick.M

    Could you tell me how to get the count of custom AIF Services and System Services ?


Email [email protected] with any questions you have pertaining to this course.

New CPE Accredited Courses Now Available for Dynamics AX, GP, and NAVEARN CREDITS TODAY