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() { #Aif 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; break; } } } } 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) try { $bcassembly = [Reflection.Assembly]::Loadfile($AXBCpath) $ax = new-object Microsoft.Dynamics.BusinessConnectorNet.Axapta $ax.logon("","","","") $xSession = $ax.CreateAxaptaObject("XSession") $AOSName = $xSession.call("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 } else { 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
[…] post Validate AIF ports if they are running in AX appeared first on DAXRunBase blog by Vilmos […]
[…] https://www.daxrunbase.com/2016/08/17/validate-aif-ports-running-ax/ […]