Empty Internet cache/temp from NAV after connect. url?

BlackMagic
Member Posts: 38
Hi people.
Im working on a project where I need to periodically connecting an URL to get a XML file for updating the Item Card in NAV. The URL connecting code is look like this:
Variables:
XMLhttp: 'Microsoft XML, v3.0'.XMLHTTP
connStr: Text
XMLDOMDoc: 'Microsoft XML, v3.0'.DOMDocument
Code
CREATE(XMLhttp);
XMLhttp.open('get',connStr,FALSE); //Connecting url (= connStr)
XMLhttp.send;
IF ISCLEAR(XMLDOMDoc) THEN
CREATE(XMLDOMDoc);
XMLDOMDoc := XMLhttp.responseXML;
XMLDOMDoc.save(_savePath); //Saving the XML file locally
There is no problem with connecting the URL and saving the XML file. But my problem is that if I dont restart Navision after each connecting time, then it just download the cached/temporary XML file from last time, so that I will not get the new updated data.
My question is therefore, how can I clear this cache from NAV so that it will download the new XML file each time when I run the code?
Is there an automation for this, or can you recommend another method for getting the new XML file.
Thank for advance.
Im working on a project where I need to periodically connecting an URL to get a XML file for updating the Item Card in NAV. The URL connecting code is look like this:
Variables:
XMLhttp: 'Microsoft XML, v3.0'.XMLHTTP
connStr: Text
XMLDOMDoc: 'Microsoft XML, v3.0'.DOMDocument
Code
CREATE(XMLhttp);
XMLhttp.open('get',connStr,FALSE); //Connecting url (= connStr)
XMLhttp.send;
IF ISCLEAR(XMLDOMDoc) THEN
CREATE(XMLDOMDoc);
XMLDOMDoc := XMLhttp.responseXML;
XMLDOMDoc.save(_savePath); //Saving the XML file locally
There is no problem with connecting the URL and saving the XML file. But my problem is that if I dont restart Navision after each connecting time, then it just download the cached/temporary XML file from last time, so that I will not get the new updated data.
My question is therefore, how can I clear this cache from NAV so that it will download the new XML file each time when I run the code?
Is there an automation for this, or can you recommend another method for getting the new XML file.
Thank for advance.
0
Comments
-
May be you can add some HTTP header to include no-cache setting.
Adding something like thisinto HTTP request header:<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="Sat, 01 Dec 2001 00:00:00 GMT">
when getting the document...0 -
Hi Kine good idea. But i cannot make use of this solution, because i request the XML file just by connecting af internet url that look like: http://...filename.xml and not via XML request.0
-
You are using XMLHTTP class - it is sending HTTP request, answer is the XML file. Do not mix XML and HTTP. The automation have function "setRequestHeader", where you can set the parameters of the HTTP header which will be send to the server.
it means add something like this:XMLhttp.setRequestHeader('Pragma','no-cache'); XMLhttp.setRequestHeader('Cache-Control','no-cache'); XMLhttp.setRequestHeader('Expires','Sat, 01 Dec 2001 00:00:00 GMT'); XMLhttp.Send;
This will add HTTP header parameters. For more info search something more about HTTP headers like there: http://www.cs.tut.fi/~jkorpela/http.html0 -
BlackMagic wrote:Hi people.
Im working on a project where I need to periodically connecting an URL to get a XML file for updating the Item Card in NAV. The URL connecting code is look like this:
Variables:
XMLhttp: 'Microsoft XML, v3.0'.XMLHTTP
connStr: Text
XMLDOMDoc: 'Microsoft XML, v3.0'.DOMDocument
Code
CREATE(XMLhttp);
XMLhttp.open('get',connStr,FALSE); //Connecting url (= connStr)
XMLhttp.send;
IF ISCLEAR(XMLDOMDoc) THEN
CREATE(XMLDOMDoc);
XMLDOMDoc := XMLhttp.responseXML;
XMLDOMDoc.save(_savePath); //Saving the XML file locally
There is no problem with connecting the URL and saving the XML file. But my problem is that if I dont restart Navision after each connecting time, then it just download the cached/temporary XML file from last time, so that I will not get the new updated data.
My question is therefore, how can I clear this cache from NAV so that it will download the new XML file each time when I run the code?
Is there an automation for this, or can you recommend another method for getting the new XML file.
Thank for advance.// XmlDocIn = 'Microsoft XML, v3.0'.DOMDocument CREATE(XmlDocIn); XmlDocIn.async := FALSE; IF NOT XmlDocIn.load('http://www.xyxyxy.com.tr') THEN ERROR('error text');
I am using this method without problem.. i am sure that evenif http response is not signed as "no-cache" or expiration date, this works..
also you can try POST method instead of GET. as far as i remember, web server and browser do not process cached documets when POST method is used.0 -
Hi All,
I also have same problem like BlackMagic.
I already tried
XmlDomDoc.async = FALSE
and
XMLHttp.setRequestHeader('Pragma','no-cache');
XMLHttp.setRequestHeader('Cache-Control','no-cache');
XMLHttp.setRequestHeader('Expires','Sat, 01 Dec 2001 00:00:00 GMT');
but still can't worked. The XML seems to be saved somehow on the cache, because it will return same xml everytime.
Please advise
many thanks for your help0
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