I have the following code:
Dim request, oXMLHttp, url
url = "WEBSITE"
request = "<?xml version='1.0' encoding='utf-8'?>" & _
"<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">" & _
"<soap:Body>" & _
"<CheckItems xmlns=""OTHERWEBSITE"">" & _
"<ItemsNumbers>" & _
"<string >1</string>" & _
"<string >2</string>" & _
"<string >3</string>" & _
"</Items>" & _
"<LicenseKey>KEY</LicenseKey>" & _
"</CheckItems>" & _
"</soap:Body>" & _
"</soap:Envelope>"
Set oXMLHttp = CreateObject("MSXML2.ServerXMLHTTP")
oXMLHttp.open "POST", url, False
oXMLHttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
oXMLHttp.send request
response = oXMLHttp.responseText
Set objFSO=CreateObject("Scripting.FileSystemObject")
outFile="C:\Path\Test.txt"
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write oXMLHttp.responseText
objFile.Close
The issue is that rather than 3 items I have say, 500 items, and running it this way causes a timeout. One suggestion to fix this is to instead set up a loop so that I instead have:
Dim request, oXMLHttp, url
url = "WEBSITE"
items = (1,2,3,4...n)
for Each item in items:
request = "<?xml version='1.0' encoding='utf-8'?>" & _
"<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">" & _
"<soap:Body>" & _
"<CheckItems xmlns=""OTHERWEBSITE"">" & _
"<ItemsNumbers>" & _
"<string >item</string>" & _
"</Items>" & _
"<LicenseKey>KEY</LicenseKey>" & _
"</CheckItems>" & _
"</soap:Body>" & _
"</soap:Envelope>"
Next item
The problem is, as you might be able to see, I don't know how to set up a loop properly at all. How can I modify this code so that the loop properly executes and so that each iteration is posted to the .txt file as in the first code example? Thanks for any and all help!
UPDATE: I also receive the error 800A03EE "Expected ')'" when trying to create an array. I'm not sure where it wants the additional right bracket.
items = ("A",
"B",
"C",
...,
"Z")
forloop. Have you looked for one? Loops are very basic programming structures.response = oXMLHttp.responseTextfor example?