Today I would like to discuss with you how to implement a Web service for Dynamics NAV and to interact with this service from Dynamics NAV C/SIDE Client or even web server.
My target was to build a NAV database (because employees are used to work with it's interface) with online access. In this online database additional information about customers (such as bonus balance) should be stored. Information about customer bonus balance should be available not only in NAV working database, but in internet, too. Further more, when posting a discount in NAV operational database, customer bonus balance should be reduced.
From the system point of view, the Navision Application Server, connected to bonus database, should be started. Certain TCP ports should be opened. When the message come to this port some event should be triggered, and a response should be posted back. The language for this interaction should be XML.
Codeunit 1, Trigger 99 NASHandler(ATASID : Text[260])
GenSetupL.GET;
GenSetupL.TESTFIELD("NAS Application Port");
IF ISCLEAR(CC) THEN CREATE(CC);
IF ISCLEAR(SBA) THEN CREATE(SBA);
CC.AddBusAdapter(SBA, 0);
SBA.OpenSocket(GenSetupL."NAS Application Port", '');
MESSAGE(StartedNASTxt, GenSetupL."NAS Application Port");
where
CC Automation 'Navision Communication Component version 2'.CommunicationComponent
SBA Automation 'Navision Socket Bus Adapter'.SocketBusAdapter are the global variables. After adding CC variables the new trigger was created automaticly:
CC::MessageReceived(VAR InMessage : Automation "''.IDISPATCH")
From the system point of view, the Navision Application Server, connected to bonus database, should be started. Certain TCP ports should be opened. When the message come to this port some event should be triggered, and a response should be posted back. The language for this interaction should be XML.
Codeunit 1, Trigger 99 NASHandler(ATASID : Text[260])
GenSetupL.GET;
GenSetupL.TESTFIELD("NAS Application Port");
IF ISCLEAR(CC) THEN CREATE(CC);
IF ISCLEAR(SBA) THEN CREATE(SBA);
CC.AddBusAdapter(SBA, 0);
SBA.OpenSocket(GenSetupL."NAS Application Port", '');
MESSAGE(StartedNASTxt, GenSetupL."NAS Application Port");
where
CC Automation 'Navision Communication Component version 2'.CommunicationComponent
SBA Automation 'Navision Socket Bus Adapter'.SocketBusAdapter are the global variables. After adding CC variables the new trigger was created automaticly:
CC::MessageReceived(VAR InMessage : Automation "''.IDISPATCH")
Then the new trigger for proceeding incoming request was created and the next code was added: