Programming with the "Navision Socket Bus Adapter"

Henry@columbus
Member Posts: 24
Hello,
I’m trying to create a winsock client application with the "Navision Socket Bus Adapter". I’m having trouble with the “MessageReceived” trigger in my client. There’s no way to get the client to receive a message.
Here’s my code:
Can anybody please help me ? :roll:
Thanks
I’m trying to create a winsock client application with the "Navision Socket Bus Adapter". I’m having trouble with the “MessageReceived” trigger in my client. There’s no way to get the client to receive a message.
Here’s my code:
OnRun //Check if ComCOm is clear IF ISCLEAR(ComCom) THEN IF NOT CREATE(ComCom) THEN ERROR('Failed to create Communication Component'); //Check if Socket Bus Adapter is clear IF ISCLEAR(SBA) THEN IF NOT CREATE(SBA) THEN ERROR('Failed to create SBA'); // Add the SBA to the Comunication Component ComCom.AddBusAdapter(SBA, 0); OutMsg:= ComCom.CreateoutMessage('Sockets://localhost:5678'); OutStr:= OutMsg.GetStream(); OutStr.WRITE('First Text'); OutMsg.Send(0);The onevent trigger from the Comunication Component
ComCom::MessageReceived@1(VAR InMessage:Automation:'.IDISPATCH"); //Displays a Message if something happens MESSAGE('Message Received!');
Can anybody please help me ? :roll:
Thanks
0
Comments
-
Hello Henry,
your example is quite right, but I`m missing
one small line of code...
SBA.OpenSocket(<your port>,'');
you have to insert this line before adding your busadapter to the comcom object.
<your port> means the port you want the communication component to listen at.
good luck...
stefan0 -
Hello,
Thanks for your answer.
I did exactly what you suggested, but it’s still not working.
I’m getting the following message: The call to member Opensocket failed. SocketBusAdapter. SocketBusAdapeter.1 returned the following message:
Cannot open socket.
This is because I’m already running a socket server. My goal is to communicate with this server.
This is my code://Check if ComCOm is clear IF ISCLEAR(ComCom) THEN IF NOT CREATE(ComCom) THEN ERROR('Failed to create Communication Component'); //Check if Socket Bus Adapter is clear IF ISCLEAR(SBA) THEN IF NOT CREATE(SBA) THEN ERROR('Failed to create SBA'); SBA.OpenSocket(5678,''); // Add the SBA to the Comunication Component ComCom.AddBusAdapter(SBA, 0); OutMsg:= ComCom.CreateoutMessage('Sockets://localhost:5678'); OutStr:= OutMsg.GetStream(); OutStr.WRITE('First Text'); OutMsg.Send(0);
Henry0 -
Hello Henry,
Stefan is right. You have written code to send data over the socket (first part) -> CLIENT and you have written code to receive data (second part) -> SERVER. But I'm also missing the Opening of the socket.
CREATE(ComCom);
CREATE(Socket);
ComCom.AddAdapter(Socket, 0);
Socket.OpenSocket(12000, ''); // Opening Port 12000
This code has to be in the "on run"-Trigger of the SERVER side. (second part).
But the application server installation has a small but usefull (unfortunatly hidden) online help: c:\program files\shared files\navision\communication component\devguide.chm.
Here you'll find two very easy examples (sending and receiving) for each kind of adapter. I'll think this will help.
Regards
Christian0 -
Hi , is it possible to use "MessageReceived" event for communicating with "BlackBox" which sends answer to dynamically changing port opened when sending messages to that remote machine ?
Or Am I able to tell NAV automation which local port should id open for sending message ?
Thank you0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 320 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