Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 73760

Failure to catch exception in service method when exposed as inbound port - why?

$
0
0

The following service method never executes the catch block.  

[SysEntryPointAttribute(false)]

public str testExceptions()

{

   str returnValue = "Success";

   try

   {

       error("Error in code.");

       throw Exception::Error;

   }

   catch

   {

       info("in catch block.");

       returnValue = "Caught exception #1";

   }

   return returnValue;

}

The error returned from the service is:

<AifFault xmlns="schemas.microsoft.com/.../Fault" xmlns:i="www.w3.org/.../XMLSchema-instance">

<CustomDetailXml i:nil="true"></CustomDetailXml>

<FaultMessageListArray i:nil="true"></FaultMessageListArray>

<InfologMessageList xmlns:b="schemas.datacontract.org/.../Microsoft.Dynamics.AX.Framework.Services">

<b:InfologMessage>

<b:InfologMessageType>Info</b:InfologMessageType>

<b:Message>inside Message.</b:Message>

</b:InfologMessage>

<b:InfologMessage>

<b:InfologMessageType>Error</b:InfologMessageType>

<b:Message>inside Error in code.</b:Message>

</b:InfologMessage>

</InfologMessageList>

<StackTrace>

at Dynamics.Ax.Application.CCPreAuthorizeService.Testexceptions() in CCPreAuthorizeService.testExceptions.xpp:line 13

at Microsoft.Dynamics.Ax.Services.SHICCPreAuthorizationService.Microsoft.Dynamics.Ax.Services.SHICCPreAuthorizeService.Testexceptions(SHICCPreAuthorizeServiceTestExceptionsRequest testExceptionsRequest)

</StackTrace>

<XppExceptionType>3</XppExceptionType>

</AifFault>

The same method returns successfully - returning "Caught Exception #1" when executed from a job or within AX.  

I suspect that (because AX does not support catching exceptions from within transactions) this is because the service is somehow wrapping this in a transaction, but I can't figure out how to circumvent that.  

Does anyone have any insight?  Is anybody able to replicate? Thanks in advance.

APB


Viewing all articles
Browse latest Browse all 73760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>