Record Web Service Calls and Errors

jwilder
Member Posts: 263
We have a Web Site that is calling NAV via Web Services (NAV 2009 SPI) for certain things such as Inventory Qty, Customer Comments etc...
I have created a web service log table in NAV that records the Function, Time, Parameters passed in and the return response. So when the website calls Web Services the first thing the function does in NAV is records this Web Service record.
My problem is that I am unble to record errors in the Web Service Log since upon error NAV rolls back. It does a great job of passing the error back to the calling web service but I am wondering if there is a way to capture the Error and record it to the log table that I created. An example of where this works is the Navision Timer 1.0 .dll that works nicely with a Single instance NAS Codeunit.
I have created a web service log table in NAV that records the Function, Time, Parameters passed in and the return response. So when the website calls Web Services the first thing the function does in NAV is records this Web Service record.
My problem is that I am unble to record errors in the Web Service Log since upon error NAV rolls back. It does a great job of passing the error back to the calling web service but I am wondering if there is a way to capture the Error and record it to the log table that I created. An example of where this works is the Navision Timer 1.0 .dll that works nicely with a Single instance NAS Codeunit.
Jason Wilder
jwilder@stonewallkitchen.com
jwilder@stonewallkitchen.com
0
Comments
-
are you 2009 or 2009 sp1?
in 2009 commits were ignored and you can write your code in sp1
if not codeunit.run and then
get last error
write it to log
commit
error(getlasterror);0 -
SPI.
Great suggestion and my current structure (Web Service Codeunit calling another codeunit's OnRun) can easily accommodate your suggestion. I'll try it out and get back to you.Jason Wilder
jwilder@stonewallkitchen.com0 -
Or you can use one "workaround". Create new table, save it. After that, switch the LinkedObject to true, and the newly displayed property LinkedInTransaction set to NO. This will exclude this table from the transactions and what you will save there it will be there even after rollback... ;-) CONS: NAV backup will not backup this table...0
-
Kamil good suggestion (I didn't know that) but the problem is I have no opportunity to save the error since there is no OnError trigger.
ara3n your suggestion works but I was wrong about it flowing good with what I already have. To call Codeunit.Run requires quite a bit of restructuring with what I already have.
All great suggestions, any other thoughts?Jason Wilder
jwilder@stonewallkitchen.com0 -
I don't it requires a lot of restructuring.
You can create a new Codeunit.
create a new function in it called set parameters.
Inside this codeunit call your existing codeuni on the run trigger.
clear(newCU);
newCU.setParameers(Customer, Comments, ItemNo., etc, etc);
If not NewCu.run then begin
end; else begin
end;0 -
I agree if it was just one Function being called it would not be a problem. But I have 7 Functions all with different parameters (and we will be adding more). An idea would be to add a SetParameter for each Datatype.
The SetParameter functions certainly solves the problem I will keep it in mind but it just doesn't seem worth it at this point. It makes the code less clear and adds another codeunit to the process.
Thanks for your help!Jason Wilder
jwilder@stonewallkitchen.com0 -
Create a new function called insert Error log.
In your webservice C# code write call this function in your code.
Try
{
Webservice.callsomefunction;
} catch
{
Webservice.insertlog(EventError);
}0
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