1. Alfredo Santibanez
  2. PowerBuilder
  3. Tuesday, 18 February 2020 17:24 PM UTC

Hi,

I am having an issue with an specific web-service GET, that seems to return me results from a cache, unless I exit from PB dev enviroment or close the application.

The process to make the call looks normal to others I use and follows most PB samples, code is included bellow.

On the same computer, using POSTMAN the web-service returns a new result each time.  Finding more values in this tool, I found that it adds more headers, called "temporary headers" autogenerated, but including them made no changes.

The first time is executed after initialization app or PB then  getallResponseHeaders, returns content type, transfer encoding and date/time, plus the correct Body.  All subsequent calls only returns only conten type and transfer encoding, no date/time and always the first Body.  It will only change after a new start of the PB or the application.

Any idea of what is happening and how to correct it?  Some more headers?

I can be a problem with the web-service, but works on Postman.

Best Regards

Alfredo

 

CODE:

try
    loo_xmlhttp = CREATE oleobject
    loo_xmlhttp.ConnectToNewObject("Msxml2.XMLHTTP.6.0")
//   loo_xmlhttp.ConnectToNewObject("Msxml2.XMLHTTP")
    loo_xmlhttp.open("GET", requestendpoint, false)
    loo_xmlHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
    loo_xmlHTTP.setRequestHeader("Authorization",authorization)
    loo_xmlHTTP.setRequestHeader("correlationId",referencia)
    loo_xmlHTTP.setRequestHeader("posId",posid)
    loo_xmlHTTP.setRequestHeader("merchantId",merchantid)

    loo_xmlHTTP.setRequestHeader("Accept","*/*")  //postman autogenerated
    loo_xmlHTTP.setRequestHeader("Cache-Control","no-cache") //postman autogenerated
    loo_xmlHTTP.setRequestHeader("Connection","keep-alive") //postman autogenerated

    loo_xmlhttp.send()
    
    
    ls_status_text = loo_xmlhttp.StatusText
    ll_status_code = loo_xmlhttp.Status        
    ls_html = loo_xmlhttp.getAllResponseHeaders()
  //  ls_html =string( loo_xmlhttp.ResponseBody(),EncodingUTF8!)
   // ls_html = loo_xmlhttp.responseText


        if ll_status_code<>200 then
                destroy loo_xmlhttp
                return -1
        end if
catch (OLERuntimeError oer)
     MessageBox("OLE  Error", Oer.GetMessage())
catch (runtimeerror er)
     MessageBox("Runtime Error", er.GetMessage())
CATCH (Throwable lth_exception)           
     MessageBox("T Error", lth_exception.GetMessage())
FINALLY
    loo_xmlhttp.DisconnectObject()
    destroy loo_xmlhttp
end try

 

 

 

Accepted Answer
Roland Smith Accepted Answer Pending Moderation
  1. Tuesday, 18 February 2020 17:41 PM UTC
  2. PowerBuilder
  3. # Permalink

The Msxml2.XMLHTTP COM object is part of WinInet (the internals of Internet Explorer) and this is standard behavior for that component.

Probably the most common way to get around it is to add a dummy argument to the URL querystring that uses a random value that changes every time. That causes a 'no match' condition with the cache.

You can also add a request header of "If-None-Match" with a random value.

 

 

Comment
  1. Alfredo Santibanez
  2. Tuesday, 18 February 2020 18:24 PM UTC
Great, just added ?dummy=<a changing value>

Thanks Roland
  1. Helpful
There are no comments made yet.


There are replies in this question but you are not allowed to view the replies from this question.