Options

I could use some help for a tcp wrapper for NAV2013

SunsetSunset Member Posts: 200
edited 2014-12-16 in NAV Three Tier
With the absence of the old automations, I find myself in need of a few hints for a tcp wrapper/listener for NAV2013.

Background: I send a XML file to an internal port, and will recieve an (String) answer back from another program on how the xml was handled.

For sending the xmlfile I have
IF ISNULL(TcpClient) THEN
  TcpClient := TcpClient.TcpClient; //System.Net.Sockets.TcpClient

TcpClient.Connect("Network IP", Network Port");
Writer := Writer.StreamWriter(TcpClient.GetStream); //Writer is System.IO.StreamWriter

// Write info about the file that is going to be sent
Writer.Write('Document info here');
Writer.Write('');
Writer.Write('');
IF ISNULL(XMLDOM) THEN
  XMLDOM := XMLDOM.XmlDocument;

XMLDOM.Load(XMLFilename);
Writer.Write(XMLDOM.OuterXml);
Writer.Flush;

This works like a charm. The other program recieves everything it needs, and responds. And so my problem begins. No matter how I try to get the response it ends in tears :(

I've tried with StreamReader, NetStream, straight from TcpClient but it just won't read the string i get returned. The closest I've got is with
netStream.Read(dnBytes, 0, TcpClient.ReceiveBufferSize); //dnBytes is System.Byte
but then it stops no matter how I try to get the byte to a string ](*,)

Any suggestions would be appreciated
Don't just take my word for it, test it yourself

Comments

  • Options
    BardurKnudsenBardurKnudsen Member, Microsoft Employee Posts: 137
    I am not sure if it matches your needs, but you could take a look at NAV2015, codeunit 1290 "Web Service Request Mgt." which does much of the same.
    Bardur Knudsen
    Microsoft - Dynamics NAV
Sign In or Register to comment.