Exception handling doesn't work in AIF service

Hi ,

I have a requirement to get XML as a string and loop through multiple records in XML and process something.

C# will pass XML as a parameter through AX AIF service. 

The issue is if I am lopping with 10 records and if error comes in 4 th record it stops there. I tried with try catch ,

but catch block is not getting executed. 

I actually want to process all 10 records and display error in error log.

Example: Out of 10 records, 7 records will be successful and 3 records might be failed and these should be shown in error log.

Any idea how to proceed.


  • Look at the TTS level in debugger - if it's not zero, you won't be able to catch exceptions.
    Please never forget to attach a tag with your version of AX (e.g. AX 2012) when creating new threads. If you mentioned the version and the type of services you're using, we probably could have answer it straight away without you debugging your code.
  • In reply to Martin Dráb:

    Thanks Martin, It is AX 2009. I only created very small service method named "Register". I have not kept any TTSBEGIN or TTSCommit in my code. It is showing TTSLevel as 2. Please note i executed this new service from C#.net. If some thing fails in try while looping it is not coming to Catch. (I also tried keeping ttsBegin and tssCommit and it showed level 3.)

    I used appl.ttsLevel() command to find the level of TTS. Could you please suggest something.

    Your statement "Look at the TTS level in debugger - if it's not zero, you won't be able to catch exceptions.".

    What shall i do to rectify this issue.

  • In reply to aliAX:

    If it's in AX 2009, you're probably talking about document services.
    As I said, the fact that you're inside a transaction is the reason why you can't catch exceptions. When an exception occurs, the transaction is rolled back and all remaining code inside the transaction block is skipped - including your catch statement.
    If you want to find where them transaction is started, try looking at Microsoft code executed before your code. Again, the debugger can help you, because it shows the stack of calls.
  • In reply to Martin Dráb:

    Thank-you so much for the perfect answer. Appreciated. As you have mention exception cannot be handled I too observed the same. I started using document service now using some create operation.

    To debug the code where it started the TTSBegin using C#, Sadly I cant do that.