Normally, when we consume AIF Service, we use this code like below to handle Error messages
1
2
3
4
5
6
7
8
9
10
11
| try
{
client.register(ctx, contract);
Console.WriteLine("items registed on Trans Id: " + contract.InventTransId + " with " + contract.Qty + " quantities.");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(string.Format("Ex: {0}", ex.Message));
Console.ReadLine();
}
|
If it cause error, message would return like this

If you want to know more details, you have to go In Dynamics ax AIF Exceptions form then check

It’s quite hard for 3rd party developer, especially they don’t have right to access AX server.
Anyway, we can get meaningful error message by doing below steps
- Check that box in AIF inbound ports

- Use
FaultException
class to get message
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| try
{
client.register(ctx, contract);
Console.WriteLine("items registed on Trans Id: " + contract.InventTransId + " with " + contract.Qty + " quantities.");
Console.ReadLine();
}
catch (System.ServiceModel.FaultException<ItemsRegistration.RegRef.AifFault> aifFault)
{
//FaultMessageList[] list = aifFault.Detail.FaultMessageListArray[0];
InfologMessage[] list = aifFault.Detail.InfologMessageList;
foreach (InfologMessage message in list)
{
Console.WriteLine(message.Message);
}
Console.ReadLine();
}
|
what we got

Thank you for reading.