Accessing CodeUnits Via COM/SOAP

quantum00
quantum00 Member Posts: 5
How can one access CodeUnits via COM, SOAP, or any other external synchronous means (no MSMQ please)?

We need to be able to have this ability in order to integrate Navision into our more powerful systems, our .NET and COM based systems, and, of course, our websites.

We are on Navision 3.7, but we can move to 4.0 if we have to.

Comments

  • Saint-Sage
    Saint-Sage Member Posts: 92
    It depends on exactly what you want to do.

    First, why do you want to avoid MSMQ? Is it because of the difficulty or fault instability, or a matter of timing?

    Basically you could connect to a Navision table, and insert a job request. Then have some type of timer similar to job scheduler that goes in every few seconds/minutes and looks in that table for new jobs to execute. If it finds one, it then executes it.

    Instead of a table you could create a custom DLL that has functions which you call in .NET that in turn fire a trigger in the automation. If this automation were installed in a similar "job scheduler" type service either on a client or on NAS, then the events would trigger in Navision and you could do whatever you wanted off of that trigger.

    Basically it depends on what you want .NET and Navision and what you want to control those events occuring.

    I hope this helps, have a great day!

    No one loves you like the one who created you...
  • kine
    kine Member Posts: 12,562
    There is no standard way, if you are asking about that. But there are many possibilities. Ask your solution center for more. For example, you can create WebService interface for Nav and use it for calling functions etc. You can search this forum for more examples. There are plenty of them.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • quantum00
    quantum00 Member Posts: 5
    We aren't going to use MSMQ for that as it's message queuing system, not a synchronous communication system. I want to use the right tool for the job, not simply what "works". In this scenario we need something using either COM, a wrapper assembly, or a SOAP interface.

    Also, this is going to be something that happens thousands of times a second in a very synchronous manner.

    All of our logic for price computation (based on dozens of Navision tables) for our e-commerce sites are in CodeUnits. Part of our business is actually IN Navision.

    I recently, found out that one of the developers on the project was writing all price, shipping, tax, and related logic in Navision and then writing them again for the web. As the architect, I almost fell out of my chair listening to this. Needless to say, I need a way to have the outside world access these code units in Navision in a proper manner.

    If there were a way to create sinks in Navision which are then called via COM, then that would probably work. I just need an interface to Navision and an interface back.
    Saint-Sage wrote:
    It depends on exactly what you want to do.

    First, why do you want to avoid MSMQ? Is it because of the difficulty or fault instability, or a matter of timing?

    Basically you could connect to a Navision table, and insert a job request. Then have some type of timer similar to job scheduler that goes in every few seconds/minutes and looks in that table for new jobs to execute. If it finds one, it then executes it.

    Instead of a table you could create a custom DLL that has functions which you call in .NET that in turn fire a trigger in the automation. If this automation were installed in a similar "job scheduler" type service either on a client or on NAS, then the events would trigger in Navision and you could do whatever you wanted off of that trigger.

    Basically it depends on what you want .NET and Navision and what you want to control those events occuring.

    I hope this helps, have a great day!
  • kine
    kine Member Posts: 12,562
    Sorry, but MSMQ are not "Asynchronous". They are used in WebServices - Call the function, wait for answer... (it means synchronous communication). If you will look into this example: http://www.mibuso.com/dlinfo.asp?FileID=599

    you will see, that it is easy to create webservice which is communicating with other applications over SOAP/HTTP/etc. (synchronized) and with NAS over MSMQ (synchronized, if no answer till timeout, then error). You can easilly change and extend the example to your needs. I used it and now I have webservice for reading Sales Price for single customer/item/quantity, reading availability of selected quantity of some item etc. (all logic is in NAV). You just needs to add some new class into the WebService app and modify the handler in NAV to generate correct XML answer for the request (some XMLPort or using DOM or plain text).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • quantum00
    quantum00 Member Posts: 5
    I'm familiar with the age old "MSMQ for RPC calling" controversy, but as the architect, I must follow proper architectural guidelines at any and all costs, even at the cost of functionality. Using the extremely controversial MSMQ for RPC calls to emulate xml services isn't something I feel comfortable with in production environments. I'm sure it works great in places, but I can't get involved in that controversy.

    Also, this looks like it's for Dynamics. We can only use things for 3.6 (or 4.0 if needed-- not Dynamics).

    There's gotta be a way to access codeunits in another way. I have no problem with writing my own COM component or socket server to listen for SOAP or RPC messages.
    kine wrote:
    Sorry, but MSMQ are not "Asynchronous". They are used in WebServices - Call the function, wait for answer... (it means synchronous communication). If you will look into this example: http://www.mibuso.com/dlinfo.asp?FileID=599

    you will see, that it is easy to create webservice which is communicating with other applications over SOAP/HTTP/etc. (synchronized) and with NAS over MSMQ (synchronized, if no answer till timeout, then error). You can easilly change and extend the example to your needs. I used it and now I have webservice for reading Sales Price for single customer/item/quantity, reading availability of selected quantity of some item etc. (all logic is in NAV). You just needs to add some new class into the WebService app and modify the handler in NAV to generate correct XML answer for the request (some XMLPort or using DOM or plain text).
  • DenSter
    DenSter Member Posts: 8,307
    So... just in case you don't understand 'it is not possible', I will repeat it:

    It is not possible.

    You can say 'there has to be a way' all you want, but that doesn't change the fact that it is not possible. There I said it a third time :mrgreen:

    NAV does not expose methods, there is no API. You want to communicate with NAV, the best way is to use MSMQ. It is possible to program tcp/ip sockets, but that is limited in functionality as well. There's a file on the product cd called 'devguide.chm', which explains what is possible using some components that are provided with NAV. Other than that you can program C/AL code to talk to other apps, but you will not be able to expose codeunits. It is simply not possible.

    There are a number of add-ons for NAV that expose webservices, and as far as I know they all use MSMQ. This is an acceptable method of communicating.
  • DenSter
    DenSter Member Posts: 8,307
    By the way, if you're patient, you can wait for 5.1, that will have a new object type for webservice. With that version you WILL be able to expose codeunits. Well not exactly expose codeunits, but you will be able to easily publish a web service based on a codeunit.
  • quantum00
    quantum00 Member Posts: 5
    You make it sound like you said that before or something...
    DenSter wrote:
    So... just in case you don't understand 'it is not possible', I will repeat it:

    Given that MSMQ is not appropriate for synchronous communication, I'm going to scratch this project.

    End of Thread.
  • DenSter
    DenSter Member Posts: 8,307
    Not me but two other people :)
  • SobyOne
    SobyOne Member Posts: 20
    Use the Navision Application Server.
    Declare an automation variable with callbacks in a single instance codeunit and cause it to run when NAS opens a session... see \Doc\w1w1atas.pdf on Disk 1 of your Navision Installation CD.

    I've used it for direct TCP/IP Communications (.NET based), RS232 Communications (VB6 Based), and as a priority queue for releasing sales documents (using a priority queue table and Navision Timer Control).

    Note: I noticed that I'm unable to get the SQL2000 Notifications to fire from NAS... we had to use the Job Scheduler for that.
    _\~ () ]3 `/ () |\| [-
    http://www.SobyLand.com
    651-815-0698