Hallo,
Another question just arose when I was thinking about possibilities of NAV 2009 and webservices. Let's assume that I expose a Codeunit with a function via the Webservice-Table. This function then calls a number of other functions in NAV whereas some paths are not determined up front, in NAV this would normally be handled with Confirm-Dialogs. This is the NAV side. Let's imagine that a .Net-Application consumes this codunit by using the related webservice. Is it now possible in the NAV-Codeunit to retrieve some information from the calling .Net-Application in order to simulate a Confirm-Dialog for example? I could think of three and a half ways that all do not seem perfect to me. The first one would be to use some kind of COM-Object in NAV to communicate with the calling application. It might also be possible in NAV to assign a flag to a field like WaitForConfirm in a new table. The .Net-Application then would just need to listen to changes in this table. The "response" i.e. the decision of that simulated confirm-request would be stored by the .NET-Application in a second field in that table. As soon as NAV finds this answer, it could continue its function-calls. I think that an asynchronous call of the webservice would be necessary for this solution.
The third solution would be to force decisions of all Confirm-Request before the Codeunit is called. This of course is not very practical because it is not clear which confirm-request would be called before the source-code is actually executed.
Or as another more theoretical idea would it maybe be possible to modify the managed C# that is automatically created? All confirm-requests would then be replaced by another function-call that handles the dialog.
Well, maybe I am really on the wrong track or overseeing something simple but I don't see a better solution. I would be interested in your thoughts on this.
Regards,
Jut
0
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Another thing to keep in mind is, that one WebService method call is one transaction - so you want to keep these things of a size, where you know what is going on.
One WebService method call being one transaction has the advantage that if somethings fails - everything rolls back - and btw. COMMIT's are ignored in a WebService context.
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.
My idea was first to create a new Contact in async-mode. In a trigger (Adderss - Onvlidate) in my Contact-Table that is called from this Webservice, I had a sleep(2000) statement to wait two seconds. After the sleep-statement I made a Customer.GET-Statement for a customer #78100 that should not exist at that moment the Create-Async(cont)-Method is executed. The next C# statement was an async-call of the Customer-Webservice method to create a customer with # 78100. The C#-code looks like:
In the Contact-Table in the OnValidate-Trigger of the field Address I do have the following source code:
After my C#-Code is executed, the field "Address 2" of my Contact has the same value as the Address-field of my Customer i.e. "Address of Customer". Does this mean that the Contact-Webservice was able to perform a dirty read of the record that was going to be created by the Customer-Webservice or when and how have the database-transactions taken place in my example?
Regards,
Jut
Webservices are not an API, and you should not try to make it behave like it. Instead of splitting up transactions, you should find a way to make what you want to do into one transaction, and figure out a way to pass parameters into that process, and return a success flag or something.
RIS Plus, LLC
In fact I managed to build my Confirm-Dialog between NAV and C# just by using this logic of async-webservices. I see no risk of inconsistencies if this is done open-minded.
There's a system variable called GUIALLOWED that I've used to set default confirmation values for NAS, I wonder if you could use that for webservices as well. I don't know for sure though, maybe someone else can chime in.
RIS Plus, LLC
There is indeed a flag ISSERVICETIER that I could use for defaults but I think that default are not always a good idea - especially not in highly interactive systems like Silverlight-applications.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
RIS Plus, LLC
Reg. ISSERVICETIER - I would like to add that ISSERVICETIER is true for both Web Services and the Role Tailored Client - and should be used when handling differences between C/AL and C#.
Another function is GUIALLOWED which should be used when you want to show a dialog or like. Note that GUIALLOWED will be false for both Web Services and NAS.
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.
why i cant do commit using webservice?
i'm using nav 2009 R2
my scenario is like this :
i put 3 txt files in a folder, 2 of them is correct
1 is error...
if executed successfully must go to folder history
if error go to folder error
if i execute run my codeunit, it can import this file 1 by 1
which is 1st file executed successfully
2nd file executed successfully
3rd file cant be executed....
this scenario is correct
but if i use webservice (C#), i create looping to execute this codeunit
1 hit... can execute these 3 files
but my question is why if i have 1 error file, these 3 files will go to folder error
but if i put 2 correct files, it will go to history
weird