XMLport to import xml from file on website

jimmyf
Member Posts: 104
In Dynamics NAV 2013 I am trying run an XMLport from a codeunit that I will execute from a NAS.
The xmlport has been designed to import exchange rates. The source file is hosted on a web server however the problem I get when running the codeunit is that it errors saying it cant find the file. the message in the event viewer is .. The specified path is invalid.
My code is below. Can this actually be done via an xmlport by opening a file hosted on a webserver?
XMLFile.OPEN('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml');
XMLFile.CREATEINSTREAM(XMLInstreamStream);
XMLPORT.IMPORT(XMLPORT::"Import Exchange Rates",XMLInstreamStream);
XMLFile.CLOSE;
The xmlport has been designed to import exchange rates. The source file is hosted on a web server however the problem I get when running the codeunit is that it errors saying it cant find the file. the message in the event viewer is .. The specified path is invalid.
My code is below. Can this actually be done via an xmlport by opening a file hosted on a webserver?
XMLFile.OPEN('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml');
XMLFile.CREATEINSTREAM(XMLInstreamStream);
XMLPORT.IMPORT(XMLPORT::"Import Exchange Rates",XMLInstreamStream);
XMLFile.CLOSE;
0
Answers
-
You will first have to download the file, as the NAV file/stream object cannot handle URL's.
Use something like WebClient.DownloadFile('http....','c:\.....') and then open the local file.
See: https://msdn.microsoft.com/en-us/library/ez801hhe1 -
Duikmeester is correct on this one.
However you can always use System.XML to load the data straight from the web.
But this also means you can't use a xmlport to import your data.
Did this exact example a few years ago, wouldnt mind sharing if you want it.Austrian NAV/BC Dev0
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