How to debug AIF document service

Outbound message

\Classes\AifOutboundProcessingService\runAsUserInPartition
Comment out the content of try block:
        // runAs currentUser and process all messages in the container.         /*new RunAsPermission(runAsUserId).assert();         // BP deviation documented         runas(runAsUserId,             classnum(AifOutboundProcessingService),             staticmethodstr(AifOutboundProcessingService, processAsUser),             messageIdContainer,             runAsCompany,             '',             runAsPartition);                 // Revert the permission         CodeAccessPermission::revertAssert();         */
Add following line after the comment:
AifOutboundProcessingService::processAsUser(messageIdContainer);
\Classes\AifDispatcher\dispatchOperation
Comment out following line:
//new AifDispatcherPermission().demand();
Do not forget to delete your changes after debugging.

Inbound message

Class to execute message processing from AX
- Add message to queue
- Copy/Paste message guid to the class main method
- Set break point to the right place
- Execute the class
class VKTraceAif extends RunBase
{
}
static server public void main(Args args)
{
    AifMessageId    aifMessageId;
    AifDispatcherPermission b = new AifDispatcherPermission()
    ;
    AifUtil::flushAifCaches();

    b.assert();
    aifMessageId = str2guid('{A1645959-29BF-4C56-814D-B40B832C9C36}');

    VKTraceAif::processMessage(aifMessageId);

    CodeAccessPermission::revertAssert();
}
public static void processAsUser(container messageIdContainer)
{
    AifGatewayQueue gatewayQueue;
    AifMessageId    messageId;
    int             messageIdContainerIdx = 1;
    ;

    // Process all messages in the container.
    for (messageIdContainerIdx = 1; messageIdContainerIdx <= conLen(messageIdContainer); messageIdContainerIdx++)
    {
        messageId = conPeek(messageIdContainer, messageIdContainerIdx);

        new SkipAOSValidationPermission().assert();
        // BP deviation documented
        gatewayQueue.skipAosValidation(true);
        select gatewayQueue
            where gatewayQueue.MessageId == messageId;
        CodeAccessPermission::revertAssert();

        if(gatewayQueue.RecId)
        {
            gatewayQueue.CallServiceDirectly = true;
            AifInboundProcessingService::processAsyncRequest(gatewayQueue);
        }
    }
}
public static void processMessage(AifMessageId    messageId)
{
    AifGatewayQueue gatewayQueue;
    int             messageIdContainerIdx = 1;
    SkipAOSValidationPermission a = new SkipAOSValidationPermission();
    ;
    a.assert();
    // BP deviation documented
    gatewayQueue.skipAosValidation(true);
    select gatewayQueue
        where gatewayQueue.MessageId == messageId;

    if(gatewayQueue.RecId)
    {
        gatewayQueue.CallServiceDirectly = true;
        AifInboundProcessingService::processAsyncRequest(gatewayQueue);
    }
    CodeAccessPermission::revertAssert();
}



 

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units.
Join us.

Blog Tags