Error-handling when making Web Services

frande
Member Posts: 17
Hello,
I am currently working on designing a system that at first only should be runned on the NAV Classic client.
However in the short future we will proparly have to make it web-based too through Web Services.
I have a question on how the web-based system reacts if an ERROR(text) is made on a NAV codeunit-object.
Can I catch that error through and try-catch-sentence, or how to I do that?
I have been searching the WWW, but I cannot find any good explanations that helps me answer the question.
Thank you in advance,
Kristian.
I am currently working on designing a system that at first only should be runned on the NAV Classic client.
However in the short future we will proparly have to make it web-based too through Web Services.
I have a question on how the web-based system reacts if an ERROR(text) is made on a NAV codeunit-object.
Can I catch that error through and try-catch-sentence, or how to I do that?
I have been searching the WWW, but I cannot find any good explanations that helps me answer the question.
Thank you in advance,
Kristian.
Best regards,
Kristian
Kristian
0
Answers
-
The webservices catches the error-message and sends it to the client who asked for the service in case the client waits for a reply from the webservice.
Otherwise it just errors and the webservice stops running this request and waits for other requests.
If you want to avoid the erroring, you can run a codeunit that runs the real codeunit is follows:IF CODEUNIT.RUN(CODEUNIT::"Codeunit to be run") THEN .... ELSE ...
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Hello kriki,
Thank you for your response.
As you said if the client waits for a reply from the webserver it will catch the error-message.
Does it catch the error-message with a try-catch-statement, or?
Thank you in advance,
Kristian.Best regards,
Kristian0 -
Yes if you need to catch at the client side that consumes the webservice, you need to do it with a try-catch-statement.0
-
and as an add-on to this answer all transactions are rolled back if an exception is raised when invoking code in web services.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 -
freddy.dk wrote:and as an add-on to this answer all transactions are rolled back if an exception is raised when invoking code in web services.
We hit that bug. And we are proposing to make it into a feature! It can be really useful to have it also in the standard client. Especially if it works like LOCKTIMEOUT. There is also a fix for it.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Hello,
Thanks everybody for your help and your answers.
Im guided in the right direction towards designing the application.
Have a nice day!Best regards,
Kristian0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 320 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