Sunday, July 3, 2016

Web service to get Data in AX 2012

static void WebService(Args _args)
{
    ClrObject clientType;
    ClassLibrary1.ServiceReference1.ClearerServiceClient              serviceclient;      
    ClassLibrary1.ServiceReference1.ClsClearerDataContract[]          lstClearerDbContractArray;
    ClassLibrary1.ServiceReference1.ClsClearerDataContract            lstClearerDbContract;
    int                                                               i, numElement;   
    Str                                                               accountNo,Code,name;
    System.Exception ex;
    new InteropPermission(InteropKind::ClrInterop).assert();
    try
    {
        clientType = CLRInterop::getType("ClassLibrary1.ServiceReference1.ClearerServiceClient");
        serviceclient = AifUtil::createServiceClient(clientType);
        lstClearerDbContractArray  = serviceclient.GetAllClearers("GT");
        numElement =lstClearerDbContractArray.get_Count();
        for(i = 0; i < numElement; i++)
        {
            lstClearerDbContract   = lstClearerDbContractArray.get_Item(i);
            accountNo = lstClearerDbContract.get_CLR_ACCOUNT_NO();
            Code = lstClearerDbContract.get_CLR_CODE();
            name = lstClearerDbContract.get_CLR_NAME();
            info(strFmt("%1,%2,%3",accountNo,Code,name));
        }
    }
    catch(Exception::CLRError)
    {
        ex = CLRInterop::getLastException();
        info(ex.ToString());
    }
}

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...