WEB Service Transaction Role Back.
NavIndia
Member Posts: 36
I have a strange problem in doing transactions through NAV 2009 Web Service.
1) I pushed XML Documents into Navision through NAV 2009 Web Service.
2) Once the XML document hits Nav, a codeunit will parse the XML Document and then insert data into a table (lets say XMLBuffer Table), in the same codeunit I have written a COMMIT after data inserted into the XMLBuffer table (So that whatever code is executed after this “COMMIT” shouldn’t roleback the insertion of data in XMLBuffer table).
3) After commit statement I have called another codeunit that will create a Sales Order based on the data inserted in XMLBuffer table.
4) Desired Result: During the process of creating Sales Order if any error comes, then the sales order creation process should be rolled-back (till the last commit) and a error log to be created in Nav. Although the data inserted in XMLBuffer table shouldn’t rollback (as COMMIT was written after that).
5) Problem: Now the problem is that if an error comes in the sales order creation then nothing happened in Navision and no data inserted in any table despite using explicit COMMIT after inserting the data into the Table and before calling sales order creation process.
Just for Information: Rather than pushing XML through NAV 2009 Web Service, if I provide the physical path to the XML file and then run the same process than it will insert data in XMLBuffer table and if any error comes in sales order creation process, than it creates a error log else creates a sales order successfully.
As per my assumption, I think when calling from Web Service, it is taking whole process as a single transaction and if any error comes (even after using proper error handler like IF CODEUNIT.RUN THEN) it rolles back fully.
Can you suggest what can be done so that system treats it as 2 processes, called one after other, first process parses the XML and inserts into table and second creates sales order using the inserted data. If error comes in 2nd process, first one doesn’t Role Back.
Code is like this
Codeunit
{
Parse XML …..
Insert into XMLBuffer ….
COMMIT;
If SALESORDERCODEUNIT.RUN(XMLBuffer) then;
}
Regards
1) I pushed XML Documents into Navision through NAV 2009 Web Service.
2) Once the XML document hits Nav, a codeunit will parse the XML Document and then insert data into a table (lets say XMLBuffer Table), in the same codeunit I have written a COMMIT after data inserted into the XMLBuffer table (So that whatever code is executed after this “COMMIT” shouldn’t roleback the insertion of data in XMLBuffer table).
3) After commit statement I have called another codeunit that will create a Sales Order based on the data inserted in XMLBuffer table.
4) Desired Result: During the process of creating Sales Order if any error comes, then the sales order creation process should be rolled-back (till the last commit) and a error log to be created in Nav. Although the data inserted in XMLBuffer table shouldn’t rollback (as COMMIT was written after that).
5) Problem: Now the problem is that if an error comes in the sales order creation then nothing happened in Navision and no data inserted in any table despite using explicit COMMIT after inserting the data into the Table and before calling sales order creation process.
Just for Information: Rather than pushing XML through NAV 2009 Web Service, if I provide the physical path to the XML file and then run the same process than it will insert data in XMLBuffer table and if any error comes in sales order creation process, than it creates a error log else creates a sales order successfully.
As per my assumption, I think when calling from Web Service, it is taking whole process as a single transaction and if any error comes (even after using proper error handler like IF CODEUNIT.RUN THEN) it rolles back fully.
Can you suggest what can be done so that system treats it as 2 processes, called one after other, first process parses the XML and inserts into table and second creates sales order using the inserted data. If error comes in 2nd process, first one doesn’t Role Back.
Code is like this
Codeunit
{
Parse XML …..
Insert into XMLBuffer ….
COMMIT;
If SALESORDERCODEUNIT.RUN(XMLBuffer) then;
}
Regards
0
Comments
-
COMMIT are ignored by web service.0
-
If you want to process them as two separate transaction. Create two functions. Call the first function to insert the xml file. Call the second function to post the transaction.0
-
Hi Rashed,
Thanx for reply,
Actually I also tried with two separate Codeunits like one codeunit for XML importing and another codeunit to process the sales order creation and publish both Codeunits in WEB SERVICE Table. Now the problem is that I can’t ask client to use two separate URL for execute both Codeunits, instead of doing this I create one more webservice as a abstract layer and ask client to use that URL in their reference.
And in my Abstract layer I set web reference to both my NAV Codeunits. And in a function ProcessRequest (in abstract layer) i put code like this
ProcessRequest //Function in my Abstract Layer
Try
{
Call ImportXML Webservice(request xml, response xml )
}
Catch
{
Exception show if any;
}
Finally
{
Call SALESORDERCODEUNIT();
}
But its still not working.
Thanx
Regards0 -
what is not working? You get an exception when calling SALESORDERCODEUNIT and this causes the roleback of ImportXML ?0
-
Yes, when I call the web service n push the xml then it won't segregate it into two processes. If any error comes in SALESORDERCREATION batch then the whole transaction role backed (including xml importing process).
In fact in SALESORDERCREATION batch i also put code like IF SALESORDERCRATION.RUN THEN;
Regards,0 -
can you paste your navision code for the two functions?0
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
