Options

Polling a Path for new .xml files

erugalathaerugalatha Member Posts: 120
Hi,

Is it possible to poll a file path from Navision CodeUnit every 4 - 5 minutes to find out if any new .xml files have been dropped into the path folder?

When a new file exists I want to trigger an XML Import on it and then delete it. Is there a way to do this does anyone know?

Thanks for any help.

Comments

  • Options
    lzrlzr Member Posts: 264
    You can use Navision application server (NAS).
    Navision developer
  • Options
    DenSterDenSter Member Posts: 8,304
    Yes you can do this. You should write a new codeunit and make it a single instance codeunit. In this single instance codeunit you create a timer object and run the code in the OnTimer event.

    You should be able to find plenty of file examples in this forum.

    What lzr is saying is that you can use NAS to run this process as an unattended service on a server computer, so you don't have to depend on an open client session. This would still run the codeunit though, so that part is still the same.

    Something else to consider is to write a codeunit that monitors a message queue. The advantage is that this is event driven, so the codeunit reacts to receiving a message. The code itself would be very similar, except that you don't poll a folder, you just process the XML directly.
  • Options
    erugalathaerugalatha Member Posts: 120
    Thanks for your replies. I presume you mean the MMQ when you say message queue?

    If I went down that route would the XML file have to be "pushed" to the navision server or could I pick it up somewhere else?

    The scenario is that I will be sent an XML stream/file to a URL. This stream/file will appear in a folder on our webserver (this is why I was thinking of polling the folder that it is dropped into). IF the code executed by the NAS can monitor a message queue then do you have any suggestions on how I will get the XML from the webserver to the navision server message queue?

    At the moment there is no link between the webserver and the navision server as they are not on the same network.

    Thank you again.
  • Options
    DenSterDenSter Member Posts: 8,304
    Yes MSMQ, Microsoft Message Queueing, the windows component. NAS itself is an unattended Navision client that runs as a windows service, it has nothing to do with the message queue. You can program NAS to do just about anything, so polling a folder is a valid thing to do, it's just not event driven.

    If you want to do something with MSMQ, then you will have to figure out a way to send the incoming XML document into one, so that Navision can pick it up. Note that Navision can only read from/write to a NON-transactional queue. The queue itself can be anywhere within the domain, as long as the NAS user has access to it.

    For XML programming, Navision uses the DOMDocument object model to pick up XML from the queue, you can take a look at the Biztalk codeunits for samples.
  • Options
    erugalathaerugalatha Member Posts: 120
    Cool, thanks again.
    I will investigate further. \:D/
Sign In or Register to comment.