Validate AIF ports if they are running in AX

It may happen that AIF ports are failing due to an error, or they do not activate when the AX AOS instance gets started. There is a way to validate AIF ports if they are running correctly using a combination of X++ code and a PowerShell script that you may find below.

Add the following to the Global class collection and do a Full CIL:

public static client boolean WIK_notStartedAIFPortExists()
    AifInboundPort  port;
    Map             serviceStatusMap;
    str             serviceTypeName, status;

    boolean ret             = false;
    boolean isPortStarted   = false;

    serviceStatusMap = appl.getServiceHostStatus();

    if (serviceStatusMap)
        while select Name from port
            serviceTypeName = strFmt('%1.%2', #DotNetServiceNamespace, port.Name);

            if (serviceStatusMap.exists(serviceTypeName))
                status            = serviceStatusMap.lookup(serviceTypeName);
                isPortStarted     = strStartsWith(status, #WcfCommunicationState_Opened);

                if (!isPortStarted)
                    ret = true;


    return ret;

And here is the PowerShell script to validate AIF ports. Please make sure you provide a comma-separated list for the AOS names, and a correct path where the Business Connector DLL could be found. Also you might want to provide credential details for the AX login if the user running the script does not have access.

# Set variables

$computerName = "TESTAOS01,TESTAOS02" -split ','
$AXBCpath = "C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin\Microsoft.Dynamics.BusinessConnectorNet.dll"

# Validate Administrative privileges and Elevated command prompt

Write-Host "Validating security privileges... " -NoNewline

if (-NOT [bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544"))
    throw "You must be running the script in an Elevated command prompt using the Run as administrator option!"

if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
    throw "You do not have Administrator rights to run this script!`nPlease re-run this script as an Administrator!"    

Write-Host "Done" -ForegroundColor Yellow

# Script for checking AIF

[ScriptBlock] $global:CheckAIFPorts =
    param ([string] $AXBCpath)
        $bcassembly = [Reflection.Assembly]::Loadfile($AXBCpath)      
        $ax = new-object Microsoft.Dynamics.BusinessConnectorNet.Axapta
        $xSession = $ax.CreateAxaptaObject("XSession")   
        $AOSName = $"AOSName")
        Write-Host -NoNewline "$AOSName AIF ports are ... "
        if ($ax.CallStaticClassMethod("Global", "WIK_notStartedAIFPortExists") -eq $false)
        #if ($ax.CallStaticClassMethod("Global", "isaos") -eq $true) #"WIK_notStartedAIFPortExists")
            Write-Host "OK" -ForegroundColor Yellow
            Write-Host "NOT OK" -ForegroundColor Red
        $logedOff = $ax.logoff()
    catch [Exception]
	    Write-Host "Failed" -ForegroundColor Red
	    Write-Host $_.exception.message

$Session = New-PSSession -ComputerName $computerName
Invoke-Command -Session $Session -ScriptBlock $CheckAIFPorts -ArgumentList "$AXBCpath"
Remove-PSSession -Session $Session

validate AIF ports


By |2016-08-17T09:02:35+02:00August 17th, 2016|Categories: AX 2012|Tags: , , , , |2 Comments

SysOperation Framework Data contract parameter name

With so many new AX 2012 R3 implementations and upgrades and the soon-to-be-released AX 7 (Rainier) around the corner I thought it is time to get back in business to publish interesting articles, now using a new home for hosting my blog:

It is always recommended to write best practice error-free code, however in some cases Microsoft forces our hands to fall back to hardcoded values. This is the case with today’s topic as well, when we would like to override values in a SysOperation Framework Data contract.

The SysOperationServiceController.getDataContractObject() method has an optional parameter, where they expect the value of ‘_dataContract’ in the example below. However we can choose to refrain from hardcoding and extract the value with Reflection.


By |2015-11-23T17:49:00+01:00October 7th, 2015|Categories: AX 2012|Tags: , , , , |0 Comments