Navision Application Server
From Dynamics
Contents |
Introduction
The Microsoft Dynamics NAV Application Server (NAS) was first introduced in Version 3.00 and is a standalone server whose purpose is to execute business logic on the NAV database (NAS is often referred to as a middle tier or n-tier application). NAS can talk to internal NAV processes as well as communicate with external services which makes it ideal for certain situations which do not require user intervention.
Dynamics NAV comes with a number of pre-built applications which make use of NAS:
- Dynamics NAV Commerce Portal
- Dynamics NAV Commerce Gateway
- Dynamics NAV Automated Data Capture System (ADCS).
- Dynamics NAV Job Scheduler
It is also possible to build custom applications that take advantage of NAS.
Technical Information
Behind the scenes, NAS is essentially a navision client that runs without a user interface (GUI). Therefore, it is not possible for the system to run forms, or any process that requires human intervention. NAS is installed as a service and can be located on a different server to where the database is installed. In most cases, installing NAS on a seperate machine is preferable, as the processes will not be competing for resources in this arrangement.
Since NAS installs as a Microsoft Windows Service, the NAS application will run using the credentials of the service. It is important to note that NAS cannot utilise NAV Database authentication, instead, it must log in using Windows Authentication. Therefore, the NAV database must be set up with a windows login in order to allow NAS entry. In addition, the NAS service must be set up to run using a windows login that exists in the NAV database. If NAS is required to interact with external services, it will do so as the service user, and will be limited to the permissions granted to that user. As an example, if NAS was set up to create files on a windows share, it would do so using the Service user ID. If that user has not been granted access to the windows share, the operation would fail.
Should the NAS application lose it's connection to the database, it will attempt to reconnect itself on a periodic basis. This provides NAS with a level of resilience, since it will attempt to reconnect if the database is shut down or if there are physical network issues. Upon startup or reconnect, NAS will log a couple of messages in the Event Log containing useful diagnostic information. If NAS encounters a problem, it will log the issue in the event log. In addition, any dialog messages or programme errors will be recorded in the event log. Dialog messages and programme errors are generating using the C/AL functions MESSAGE and ERROR.
Upon startup, NAS will run codeunit 1 and call the function with ID 99 (On English systems this function is called NASHandler). This function accepts a single parameter which NAS passes to it, containing the requested application to run. The parameter is set as part of the NAS installation. The NASHandler function will usually redirect NAS to a single instance codeunit which sets it up to either listen for events (such as via COM events), or enter a C/AL loop.
When designing applications, it is possible to detect whether NAS is running it using the C/AL keyword GUIALLOWED. An interactive client will always return TRUE to this function, while NAS will always return FALSE. With this in mind, applications can be developed so that any user interaction can be bypassed or default values supplied as a substitute.
Installing NAS
It is important that the version of NAS being installed matches the version of the database it is being installed against.
Running Multiple NAS Instances
By default, running the installer will set up a single NAS instance for the NAV database and one for the NAV SQL Server option. Running the installer again will only present the option to repair or remove the current installation. It is however possible to have multiple NAS instances running off the same server by installing manually.
To install another instance of NAS for the Dynamic NAV native server, the following files need to be copied to a new folder:
- nas.exe
- slave.exe
- dbm.dll
- fin.etx
- fin.stx
- cronus.flf
After copying the files, you will need to navigate to the folder containing the files you have just copied using the command line, then run NAS from there.
The process is much the same for the NAS SQL option, however, a different set of files has to be copied to a new folder:
- nassql.exe
- fin.etx
- fin.stx
- cronus.flf
Debugging NAS
Microsoft Dynamics NAV Application Server (NAS) was designed to run autonomously, so opportunities to interact and detect problems with programme logic are limited. It is for this reason that in version 3.60, Navision introduced the option to run NAS with a debugging option.
In order to start NAS in debugging mode, you have to run NAS off the command line using the debug keyword:
- nas startupparameter=”MYAPP”,servername=SERVER1,debug
It is also possible to load or save to a breakpoints file using the breakpoints keyword:
- nas startupparameter=”MYAPP”,servername=SERVER1,debug,breakpoints=c:\file.xml
Starting the NAS in debug mode will start NAS with the debugger window open. If you choose to turn off the debugger, it is not possible to start debugging again until the NAS is stopped and restarted again using the debug keyword.
When debugging custom applications written for NAS, it is generally easier to remember that NAS is essentially the same as the interactive client, and so, programme logic can be debugged much easier by running the NAS handler codeunit directly from the client. The NAS debugger can be used at the very end to test for GUI & permission related problems.
See also
External links
Categories: NAV | Development | C/SIDE
