I am currently trying to integrate a web service call into a Qlik application. I have successfully done this with a Macro that is triggered by a button. The xml response from the web service is saved to a temporary file, a partial reload is done, and the temporary file is deleted. I found a few helpful posts on the Qlik community to set it up. Here is the relevant portion of the macro code:
Set xmlhttp = CreateObject("Microsoft.XMLHTTP") xmlhttp.open "POST",<endpoint>,false xmlhttp.send xmlToSend Path = ActiveDocument.Evaluate("left(DocumentPath(), index(DocumentPath(), '\', -1))") FileName = Path & "response.xml" set fso = CreateObject("Scripting.FileSystemObject") set s = fso.CreateTextFile(FileName, True) s.writeline(result) s.Close() ActiveDocument.DoReload 2, true fso.DeleteFile(FileName)
My question is how would I get this to work outside of the Desktop application so that any user accessing the .qvw through AccessPoint is also able to use web service data? I have not found a way to trigger any sort of reload from within the .qvw on AccessPoioint (DoReload or any of the other Reload functions for ActiveDocument and the Reload action for a button). I am able to call the web service from AccessPoint and can set the return value into a variable but I am not able to get the xml response to be reloaded into the appropriate tables for my visualizations. Most of the data can be a day old but we are trying to use a web service to provide a real-time option for the user. I think there may be a way to do this by manually parsing the xml within the macro and using the DynamicUpdateCommand but I am looking for something that feels a little less "hacky". Any tips or examples would be greatly appreciated.
Sure, here is the complete macro (with company identifying info removed). This is VBScript and you will want to set the security to System Access/Allow System Access. You will want to get xmlToSend to match the xml you send through soapUI (or whatever testing tool you use) and change <endpoint> to the endpoint you want to send your request to.
Sub WS mrn = ActiveDocument.Fields("MRN").GetPossibleValues.Item(0).Text