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.
0
Comments
Adding something like thisinto HTTP request header:
when getting the document...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
it means add something like this:
This will add HTTP header parameters. For more info search something more about HTTP headers like there: http://www.cs.tut.fi/~jkorpela/http.html
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
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.
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 help