XMLports enable you to import data received in XML format to the Microsoft Dynamics NAV database and export data in XML format from the Microsoft Dynamics NAV database. You only need a basic knowledge of XML to design and work with XMLports. You design XMLports in XMLport Designer, which you open from Object Designer.

Saving, Compiling, and Running an XMLport

When you have designed an XMLport, you must save and compile it before you can use it. Usually, you do this when you have finished designing the XMLport. However, you may want to save an XMLport that is not yet finished and therefore cannot be compiled. You can also test-compile an XMLport without closing or saving it.

Compiling an XMLport

XMLports, like other objects in C/SIDE, must be compiled before they can be run. As described previously, you can choose to compile an XMLport when you save it.

While you are designing an XMLport, you may want to test-compile it to find possible errors. To test-compile an XMLport during design, choose the Compile option in the Tools menu.

Running an XMLport

XMLports are called from codeunits. While you are designing an XMLport, you may want to run it before it has been integrated into an application to check that it functions as you intended. To do so, you can create a test-run codeunit that calls the XMLport and either streams data to or from a file depending on whether you are importing or exporting data. The following is an example of a test-run codeunit that calls an XMLport to import data from an XML file. The code is implemented in the OnRun method.

  CopyCode imageCopy Code
TestFile.OPEN('C:\XML-Test\XML Import\Import.xml');
TestFile.CREATEINSTREAM(TestStream);
XMLPORT.IMPORT(74300, TestStream);
TestFile.CLOSE;

The four functions in the OnRun section perform the following:

  • Open the Import.xml file.

  • Create an InStream object so that the XML data can be streamed from the file.

  • Load a specific XMLport object and give it the source from which it can read and parse the incoming XML data stream.

  • Close the Import.xml file.

See Also