Monday, June 4, 2012

AX 2012 AIF Calling via WCF

Hi,
     Today we will look at "How to call a AX2012 Service into a WCF App.
The CustCustomerService (External name CustomerService) can be used to create a customer in Ax through AIF. When using the http adapter and consuming this service in a .Net Application, this is a tried and tested way to do it. Notice the DirPartyTable assignment in the code. You do not need to specify the DirParty member, but that is where the customer name is held in Ax 2012


static void WebServiceTest()
{
    using (Ax2012WebService.CustomerServiceClient custClient = new Ax2012WebService.CustomerServiceClient())
    {
        var context = new Ax2012WebService.CallContext() { Company = "ceu" };
        var customers = new Ax2012WebService.AxdCustomer
            {
                CustTable = new Ax2012WebService.AxdEntity_CustTable[] 
                    { 
                        new Ax2012WebService.AxdEntity_CustTable() 
                        { 
                            CustGroup="10", 
                            TaxGroup="CA", 
                            DirParty = new Ax2012WebService.AxdEntity_DirParty_DirPartyTable[1] 
                            {
                                new Ax2012WebService.AxdEntity_DirParty_DirOrganization() 
                                    { LanguageId = "en-us", Name = "SS 001" }
                            }
                        }
                    }
            };
        custClient.create(
            context,
            customers
            );
    }
}


Enjoy DAX!!!

No comments:

Post a Comment

Thanks for your time reviewing this blog.