Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Not applicable

Macro to load data from a webservice

Hello Friends,

Your helps are always appreciated!

I am loading data from a web server, so I  have downloaded the below script from community to achieve the same  and while executing I am getting an error saying

Expected ';'

The script below:

sub GetWebServiceData()

Define the URL of the service

url = "http://mywebservicesite.com/projets.xml"

' Define parameters to post (in this case will return data for all projects)

request = "project_id=allprojects"

Set objHTTP = Createobject("MSXML2.ServerXMLHTTP")

'Open channel

  • objHTTP.open "POST", url, False

' Send header

  • objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

' Send parameters

  • objHTTP.send request

' Get responce xml in string

responce = objHTTP.responseText

Set objHTTP = Nothing

' At this point web service responded and gave back the response xml (if there is no error)

' Common case is to return errors in xml format

' Since the returned xml is in the memory we will need to store it in local file

' Set folder name where file will be save

foldername = "C:\ProjectFiles"

' Set file name where data will be stored

filename = "xmlReponce.xml"

Set objFSO = CreateObject("Scripting.FileSystemObject")

' Check if folder exists else create it

If objFSO.FolderExists(foldername) Then

Set objFolder = objFSO.GetFolder(foldername)

Else

Set objFolder = objFSO.CreateFolder(foldername)

End If

' Check if file exists else create it

If objFSO.FileExists(foldername & filename) Then

Set objFolder = objFSO.GetFolder(foldername)

Else

Set objFile = objFSO.CreateTextFile(foldername & filename)

End If

set objFile = nothing

set objFolder = nothing

' Constant that indicate that file content will be overwritten and not appended

Const ForAppending = 2

' Open the text file

Set objTextFile = objFSO.OpenTextFile (foldername & filename, ForAppending, True)

' And paste the content

  • objTextFile.WriteLine(responce )
  • objTextFile.Close

end function

Kindly let me know your opinions

Thanks,

Kiru

2 Replies
Highlighted
MVP & Luminary
MVP & Luminary

Did you put the above text in the script editor (Ctrl-E) or the module editor (Ctrl-M)?

-Rob

Highlighted
Not applicable

Hello Rob,

Thanks so much for your time; I put the above code in module editor(Ctrl+M)

Regards,

Kiru