Web Service Transactions
igor.chladil
Member Posts: 28
Hello,
I am using native web service in NAV2009 [GB Dynamics NAV 6.0, no hotfixes].
I have the web method that contains only the code below that should basically just "log something" in the InMsg table no matter whether there was an error in CU 99500 or not:
If there is no error in CU 99500 then the record is created in InMsg table as expected.
However if there is an error in CU 99500 the rest of the code in the method is performed (as expected), but the whole transaction seems to be rolled back and there is no record in InMsg table once the WS call finishes. If the same method is called from classic client, the record is created as expected.
Could somebody please explain to me why is this happenning and how can I make this code working as expected?
Thanks ahead,
Igor
I am using native web service in NAV2009 [GB Dynamics NAV 6.0, no hotfixes].
I have the web method that contains only the code below that should basically just "log something" in the InMsg table no matter whether there was an error in CU 99500 or not:
IF CODEUNIT.RUN(99500) THEN ; InMsg.INIT; InMsg."Message ID" := 'test'; InMsg.INSERT;
If there is no error in CU 99500 then the record is created in InMsg table as expected.
However if there is an error in CU 99500 the rest of the code in the method is performed (as expected), but the whole transaction seems to be rolled back and there is no record in InMsg table once the WS call finishes. If the same method is called from classic client, the record is created as expected.
Could somebody please explain to me why is this happenning and how can I make this code working as expected?
Thanks ahead,
Igor
0
Comments
-
Try to add explicit COMMIT at the end of the function. If I remember correctly, the commits during the webservice call are working differently than expected. May be there is some issue with that.0
-
COMMIT's in code in Web Services are just ignored - everything is committed when the web service returns - and everything is aborted if an exception occurs somewhere.
It seems like the AL Exception handler doesn't work - meaning that the exception in your codeunit.run causes the Web Service to fail.
I will investigate this and file a bug if that is the case.
Have you tried outcommenting your if codeunit.run statement and verified that you actually get a log entry then?Freddy Kristiansen
Group Program Manager, Client
Microsoft Dynamics NAV
http://blogs.msdn.com/freddyk
The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.0 -
Thanks Fraddy, I was not sure about the ignoring of the commits. May be using the CLEARLASTERROR after the CODEUNIT.RUN will help to clear the error and finish the webservice correctly... :-k0
-
Thanks for your replies,
I have tried to change the code to the following one but the result was the same:IF NOT CODEUNIT.RUN(99500) THEN CLEARLASTERROR; COMMIT; InMsg.INIT; InMsg."Message ID" := 'test'; InMsg.INSERT; COMMIT; EXIT(100);
IF the CU.RUN is commented out, the code works as expected - the record is inserted in NAV.
According to me this behaviour is a bug as:
1) Web Service returns without error and with correct return value (i.e. it has reached the end). Therefore I would expect the whole DB transaction to have been successful as well.
2) Just the whole DB transaction seems to have been aborted.
Regards,
Igor0 -
It sure looks like a bug - we will look into it.Freddy Kristiansen
Group Program Manager, Client
Microsoft Dynamics NAV
http://blogs.msdn.com/freddyk
The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.0 -
Igor, have you tried to use CLEARLASTERROR before exiting in case of some error in the codeunit? May be it will clear the error stack and it will not rollback the transaction...0
-
Yes, I have tried clearing the error after the CU Run.0
-
I have logged a bug on this issue.
As the error is handled, there should be an implicit COMMIT when the Web service operation exits.
Thanks for your help!
/Hans0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
