Using WCF services in Microsoft Dynamics AX2012 R3 X++Axapta code


I need to use the external service in my Microsoft Dynamics AX2012 R3 code to fulfill some business requirement.


The steps to use wcf service in X++ are quite simple:

  1. Create the new .Net Class Library project.
  2. Adding the Service Reference in .Net Class Library.
  3. Build and Deploy the .Dll (C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin) in Client Folder
  4. Add the project to AOT if required not necessary
  5. Open AOT and add the Dll Reference by right click on the Reference node in AOT.
  6. Now with the following code you can access the external wcf service in your Microsoft Dynamics AX2012 R3 X++ code:

    static void WCFService(Args _args)
    SMTP.SMTPService.AXClient service;
    boolean ret;
    System.Exception ex;
    System.Type type;


    //by this procedure you don’t need to add the service endpoint in AX32.exe.Config
    //it will pick from the class library config
    type = CLRInterop::getType(‘SMTP.SMTPService.AXClient’);
    service = AifUtil::createServiceClient(type);

    // Service Method
    ret = service.InsertCourseItem(“testAXCode”,”ItemName”,”ItemId”,200,”descrip”);

    ex = CLRInterop::getLastException();

    #MicrosoftDynamicsAX2012 #AX2012 #WCFService#ConsumeWCFService #ConsumeWCFServiceInX++  #AX2012R3 #.Net #Consume.NetC#

    Happy Daxing with Rizz 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s