HTTP GET in VBS
Is there a way to perform an HTTP GET request within a Visual Basic script? I need to get the contents of the response from a particular URL for processing.
http vbscript request
add a comment |
Is there a way to perform an HTTP GET request within a Visual Basic script? I need to get the contents of the response from a particular URL for processing.
http vbscript request
add a comment |
Is there a way to perform an HTTP GET request within a Visual Basic script? I need to get the contents of the response from a particular URL for processing.
http vbscript request
Is there a way to perform an HTTP GET request within a Visual Basic script? I need to get the contents of the response from a particular URL for processing.
http vbscript request
http vbscript request
edited Sep 18 '16 at 23:16
feetwet
1,37432345
1,37432345
asked Oct 15 '08 at 13:47
Justin BennettJustin Bennett
6,61122227
6,61122227
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
Dim o
Set o = CreateObject("MSXML2.XMLHTTP")
o.open "GET", "http://www.example.com", False
o.send
' o.responseText now holds the response as a string.
2
Just to add the third bool parameter represents if the call is to be made async or sync. False value means it will be a synchronous call. Also the open API has two more parameter for authentication to pass Userid and password if it is required by the website being called.
– RBT
Apr 22 '16 at 10:48
1
I'm having problems using this method from Windows 2012, I think that's due to the lot of different versions released by microsoft. I am thinking of using antoher method for make an HTTP Get from vbs, any ideas??
– Raul Luna
May 11 '16 at 14:12
Simple example for a simple question. It took me 2 hours to find this, which is all I needed. Bravo!
– JediPotPie
Apr 18 '17 at 17:39
add a comment |
You haven't at time of writing described what you are going to do with the response or what its content type is. An answer already contains a very basic usage of MSXML2.XMLHTTP
(I recommend the more explicit MSXML2.XMLHTTP.3.0
progID) however you may need to do different things with the response, it may not be text.
The XMLHTTP also has a responseBody
property which is a byte array version of the reponse and there is a responseStream
which is an IStream
wrapper for the response.
Note that in a server-side requirement (e.g., VBScript hosted in ASP) you would use MSXML.ServerXMLHTTP.3.0
or WinHttp.WinHttpRequest.5.1
(which has a near identical interface).
Here is an example of using XmlHttp to fetch a PDF file and store it:-
Dim oXMLHTTP
Dim oStream
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.3.0")
oXMLHTTP.Open "GET", "http://someserver/folder/file.pdf", False
oXMLHTTP.Send
If oXMLHTTP.Status = 200 Then
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write oXMLHTTP.responseBody
oStream.SaveToFile "c:somefolderfile.pdf"
oStream.Close
End If
hey anthony! How would we specify auth keys or request arguments externally? or we can just keep that a part of the url.
– Sushant Khurana
Jun 26 '12 at 11:09
@SushantKhurana: The would depend on what the server is expecting. You an include additional headers in the request with addHeader method so if you have control of both ends you create some custom "x-myheader" header. Or you can use a "POST", add a Content-Type header like "application/x-www-form-urlencoded" and pass a urlencoded string contianing parameter to thesend
method. Or as you say include the values in the query string. It really depends on what you have available to you on the server.
– AnthonyWJones
Jun 26 '12 at 11:36
Yes. I have to do that via a Basic HTTP Authorization header only. Example Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
– Sushant Khurana
Jun 26 '12 at 12:00
@SushantKhurana@ For basic authorization just specify the username and password as the 4th and 5th parameters in the XMLHttpopen
method call.
– AnthonyWJones
Jun 26 '12 at 13:26
Thanks for the help Anthony.
– Sushant Khurana
Jul 18 '12 at 12:25
add a comment |
If you are using the GET request to actually SEND data...
check:
http://techhelplist.com/index.php/tech-tutorials/37-windows-troubles/60-vbscript-sending-get-request
The problem with MSXML2.XMLHTTP is that there are several versions of it, with different names depending on the windows os version and patches.
this explains it:
http://support.microsoft.com/kb/269238
i have had more luck using vbscript to call
set ID = CreateObject("InternetExplorer.Application")
IE.visible = 0
IE.navigate "http://example.com/parser.php?key=" & value & "key2=" & value2
do while IE.Busy....
....and more stuff but just to let the request go thru.
That is just ugly and inefficient, why would you do this? Every time you call this code you are creating an instance ofiexplore.exe
in the background which then calls winsock.dll to handle to the HTTP request, where as the Server HTTP Request objects do this directly with far less overhead.
– Lankymart
Jul 6 '16 at 9:33
add a comment |
strRequest = "<soap:Envelope xmlns:soap=""http://www.w3.org/2003/05/soap-envelope"" " &_
"xmlns:tem=""http://tempuri.org/"">" &_
"<soap:Header/>" &_
"<soap:Body>" &_
"<tem:Authorization>" &_
"<tem:strCC>"&1234123412341234&"</tem:strCC>" &_
"<tem:strEXPMNTH>"&11&"</tem:strEXPMNTH>" &_
"<tem:CVV2>"&123&"</tem:CVV2>" &_
"<tem:strYR>"&23&"</tem:strYR>" &_
"<tem:dblAmount>"&1235&"</tem:dblAmount>" &_
"</tem:Authorization>" &_
"</soap:Body>" &_
"</soap:Envelope>"
EndPointLink = "http://www.trainingrite.net/trainingrite_epaysystem" &_
"/trainingrite_epaysystem/tr_epaysys.asmx"
dim http
set http=createObject("Microsoft.XMLHTTP")
http.open "POST",EndPointLink,false
http.setRequestHeader "Content-Type","text/xml"
msgbox "REQUEST : " & strRequest
http.send strRequest
If http.Status = 200 Then
'msgbox "RESPONSE : " & http.responseXML.xml
msgbox "RESPONSE : " & http.responseText
responseText=http.responseText
else
msgbox "ERRCODE : " & http.status
End If
Call ParseTag(responseText,"AuthorizationResult")
Call CreateXMLEvidence(responseText,strRequest)
'Function to fetch the required message from a TAG
Function ParseTag(ResponseXML,SearchTag)
ResponseMessage=split(split(split(ResponseXML,SearchTag)(1),"</")(0),">")(1)
Msgbox ResponseMessage
End Function
'Function to create XML test evidence files
Function CreateXMLEvidence(ResponseXML,strRequest)
Set fso=createobject("Scripting.FileSystemObject")
Set qfile=fso.CreateTextFile("C:UsersRajkumarJoshuaDesktopDCIMSampleResponse.xml",2)
Set qfile1=fso.CreateTextFile("C:UsersRajkumarJoshuaDesktopDCIMSampleReuest.xml",2)
qfile.write ResponseXML
qfile.close
qfile1.write strRequest
qfile1.close
End Function
You need to have some commenting to supplement your code.
– theblindprophet
Jun 14 '16 at 13:27
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f204759%2fhttp-get-in-vbs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Dim o
Set o = CreateObject("MSXML2.XMLHTTP")
o.open "GET", "http://www.example.com", False
o.send
' o.responseText now holds the response as a string.
2
Just to add the third bool parameter represents if the call is to be made async or sync. False value means it will be a synchronous call. Also the open API has two more parameter for authentication to pass Userid and password if it is required by the website being called.
– RBT
Apr 22 '16 at 10:48
1
I'm having problems using this method from Windows 2012, I think that's due to the lot of different versions released by microsoft. I am thinking of using antoher method for make an HTTP Get from vbs, any ideas??
– Raul Luna
May 11 '16 at 14:12
Simple example for a simple question. It took me 2 hours to find this, which is all I needed. Bravo!
– JediPotPie
Apr 18 '17 at 17:39
add a comment |
Dim o
Set o = CreateObject("MSXML2.XMLHTTP")
o.open "GET", "http://www.example.com", False
o.send
' o.responseText now holds the response as a string.
2
Just to add the third bool parameter represents if the call is to be made async or sync. False value means it will be a synchronous call. Also the open API has two more parameter for authentication to pass Userid and password if it is required by the website being called.
– RBT
Apr 22 '16 at 10:48
1
I'm having problems using this method from Windows 2012, I think that's due to the lot of different versions released by microsoft. I am thinking of using antoher method for make an HTTP Get from vbs, any ideas??
– Raul Luna
May 11 '16 at 14:12
Simple example for a simple question. It took me 2 hours to find this, which is all I needed. Bravo!
– JediPotPie
Apr 18 '17 at 17:39
add a comment |
Dim o
Set o = CreateObject("MSXML2.XMLHTTP")
o.open "GET", "http://www.example.com", False
o.send
' o.responseText now holds the response as a string.
Dim o
Set o = CreateObject("MSXML2.XMLHTTP")
o.open "GET", "http://www.example.com", False
o.send
' o.responseText now holds the response as a string.
answered Oct 15 '08 at 14:10
svintosvinto
10.9k33442
10.9k33442
2
Just to add the third bool parameter represents if the call is to be made async or sync. False value means it will be a synchronous call. Also the open API has two more parameter for authentication to pass Userid and password if it is required by the website being called.
– RBT
Apr 22 '16 at 10:48
1
I'm having problems using this method from Windows 2012, I think that's due to the lot of different versions released by microsoft. I am thinking of using antoher method for make an HTTP Get from vbs, any ideas??
– Raul Luna
May 11 '16 at 14:12
Simple example for a simple question. It took me 2 hours to find this, which is all I needed. Bravo!
– JediPotPie
Apr 18 '17 at 17:39
add a comment |
2
Just to add the third bool parameter represents if the call is to be made async or sync. False value means it will be a synchronous call. Also the open API has two more parameter for authentication to pass Userid and password if it is required by the website being called.
– RBT
Apr 22 '16 at 10:48
1
I'm having problems using this method from Windows 2012, I think that's due to the lot of different versions released by microsoft. I am thinking of using antoher method for make an HTTP Get from vbs, any ideas??
– Raul Luna
May 11 '16 at 14:12
Simple example for a simple question. It took me 2 hours to find this, which is all I needed. Bravo!
– JediPotPie
Apr 18 '17 at 17:39
2
2
Just to add the third bool parameter represents if the call is to be made async or sync. False value means it will be a synchronous call. Also the open API has two more parameter for authentication to pass Userid and password if it is required by the website being called.
– RBT
Apr 22 '16 at 10:48
Just to add the third bool parameter represents if the call is to be made async or sync. False value means it will be a synchronous call. Also the open API has two more parameter for authentication to pass Userid and password if it is required by the website being called.
– RBT
Apr 22 '16 at 10:48
1
1
I'm having problems using this method from Windows 2012, I think that's due to the lot of different versions released by microsoft. I am thinking of using antoher method for make an HTTP Get from vbs, any ideas??
– Raul Luna
May 11 '16 at 14:12
I'm having problems using this method from Windows 2012, I think that's due to the lot of different versions released by microsoft. I am thinking of using antoher method for make an HTTP Get from vbs, any ideas??
– Raul Luna
May 11 '16 at 14:12
Simple example for a simple question. It took me 2 hours to find this, which is all I needed. Bravo!
– JediPotPie
Apr 18 '17 at 17:39
Simple example for a simple question. It took me 2 hours to find this, which is all I needed. Bravo!
– JediPotPie
Apr 18 '17 at 17:39
add a comment |
You haven't at time of writing described what you are going to do with the response or what its content type is. An answer already contains a very basic usage of MSXML2.XMLHTTP
(I recommend the more explicit MSXML2.XMLHTTP.3.0
progID) however you may need to do different things with the response, it may not be text.
The XMLHTTP also has a responseBody
property which is a byte array version of the reponse and there is a responseStream
which is an IStream
wrapper for the response.
Note that in a server-side requirement (e.g., VBScript hosted in ASP) you would use MSXML.ServerXMLHTTP.3.0
or WinHttp.WinHttpRequest.5.1
(which has a near identical interface).
Here is an example of using XmlHttp to fetch a PDF file and store it:-
Dim oXMLHTTP
Dim oStream
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.3.0")
oXMLHTTP.Open "GET", "http://someserver/folder/file.pdf", False
oXMLHTTP.Send
If oXMLHTTP.Status = 200 Then
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write oXMLHTTP.responseBody
oStream.SaveToFile "c:somefolderfile.pdf"
oStream.Close
End If
hey anthony! How would we specify auth keys or request arguments externally? or we can just keep that a part of the url.
– Sushant Khurana
Jun 26 '12 at 11:09
@SushantKhurana: The would depend on what the server is expecting. You an include additional headers in the request with addHeader method so if you have control of both ends you create some custom "x-myheader" header. Or you can use a "POST", add a Content-Type header like "application/x-www-form-urlencoded" and pass a urlencoded string contianing parameter to thesend
method. Or as you say include the values in the query string. It really depends on what you have available to you on the server.
– AnthonyWJones
Jun 26 '12 at 11:36
Yes. I have to do that via a Basic HTTP Authorization header only. Example Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
– Sushant Khurana
Jun 26 '12 at 12:00
@SushantKhurana@ For basic authorization just specify the username and password as the 4th and 5th parameters in the XMLHttpopen
method call.
– AnthonyWJones
Jun 26 '12 at 13:26
Thanks for the help Anthony.
– Sushant Khurana
Jul 18 '12 at 12:25
add a comment |
You haven't at time of writing described what you are going to do with the response or what its content type is. An answer already contains a very basic usage of MSXML2.XMLHTTP
(I recommend the more explicit MSXML2.XMLHTTP.3.0
progID) however you may need to do different things with the response, it may not be text.
The XMLHTTP also has a responseBody
property which is a byte array version of the reponse and there is a responseStream
which is an IStream
wrapper for the response.
Note that in a server-side requirement (e.g., VBScript hosted in ASP) you would use MSXML.ServerXMLHTTP.3.0
or WinHttp.WinHttpRequest.5.1
(which has a near identical interface).
Here is an example of using XmlHttp to fetch a PDF file and store it:-
Dim oXMLHTTP
Dim oStream
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.3.0")
oXMLHTTP.Open "GET", "http://someserver/folder/file.pdf", False
oXMLHTTP.Send
If oXMLHTTP.Status = 200 Then
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write oXMLHTTP.responseBody
oStream.SaveToFile "c:somefolderfile.pdf"
oStream.Close
End If
hey anthony! How would we specify auth keys or request arguments externally? or we can just keep that a part of the url.
– Sushant Khurana
Jun 26 '12 at 11:09
@SushantKhurana: The would depend on what the server is expecting. You an include additional headers in the request with addHeader method so if you have control of both ends you create some custom "x-myheader" header. Or you can use a "POST", add a Content-Type header like "application/x-www-form-urlencoded" and pass a urlencoded string contianing parameter to thesend
method. Or as you say include the values in the query string. It really depends on what you have available to you on the server.
– AnthonyWJones
Jun 26 '12 at 11:36
Yes. I have to do that via a Basic HTTP Authorization header only. Example Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
– Sushant Khurana
Jun 26 '12 at 12:00
@SushantKhurana@ For basic authorization just specify the username and password as the 4th and 5th parameters in the XMLHttpopen
method call.
– AnthonyWJones
Jun 26 '12 at 13:26
Thanks for the help Anthony.
– Sushant Khurana
Jul 18 '12 at 12:25
add a comment |
You haven't at time of writing described what you are going to do with the response or what its content type is. An answer already contains a very basic usage of MSXML2.XMLHTTP
(I recommend the more explicit MSXML2.XMLHTTP.3.0
progID) however you may need to do different things with the response, it may not be text.
The XMLHTTP also has a responseBody
property which is a byte array version of the reponse and there is a responseStream
which is an IStream
wrapper for the response.
Note that in a server-side requirement (e.g., VBScript hosted in ASP) you would use MSXML.ServerXMLHTTP.3.0
or WinHttp.WinHttpRequest.5.1
(which has a near identical interface).
Here is an example of using XmlHttp to fetch a PDF file and store it:-
Dim oXMLHTTP
Dim oStream
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.3.0")
oXMLHTTP.Open "GET", "http://someserver/folder/file.pdf", False
oXMLHTTP.Send
If oXMLHTTP.Status = 200 Then
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write oXMLHTTP.responseBody
oStream.SaveToFile "c:somefolderfile.pdf"
oStream.Close
End If
You haven't at time of writing described what you are going to do with the response or what its content type is. An answer already contains a very basic usage of MSXML2.XMLHTTP
(I recommend the more explicit MSXML2.XMLHTTP.3.0
progID) however you may need to do different things with the response, it may not be text.
The XMLHTTP also has a responseBody
property which is a byte array version of the reponse and there is a responseStream
which is an IStream
wrapper for the response.
Note that in a server-side requirement (e.g., VBScript hosted in ASP) you would use MSXML.ServerXMLHTTP.3.0
or WinHttp.WinHttpRequest.5.1
(which has a near identical interface).
Here is an example of using XmlHttp to fetch a PDF file and store it:-
Dim oXMLHTTP
Dim oStream
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.3.0")
oXMLHTTP.Open "GET", "http://someserver/folder/file.pdf", False
oXMLHTTP.Send
If oXMLHTTP.Status = 200 Then
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write oXMLHTTP.responseBody
oStream.SaveToFile "c:somefolderfile.pdf"
oStream.Close
End If
answered Oct 16 '08 at 15:00
AnthonyWJonesAnthonyWJones
163k27217288
163k27217288
hey anthony! How would we specify auth keys or request arguments externally? or we can just keep that a part of the url.
– Sushant Khurana
Jun 26 '12 at 11:09
@SushantKhurana: The would depend on what the server is expecting. You an include additional headers in the request with addHeader method so if you have control of both ends you create some custom "x-myheader" header. Or you can use a "POST", add a Content-Type header like "application/x-www-form-urlencoded" and pass a urlencoded string contianing parameter to thesend
method. Or as you say include the values in the query string. It really depends on what you have available to you on the server.
– AnthonyWJones
Jun 26 '12 at 11:36
Yes. I have to do that via a Basic HTTP Authorization header only. Example Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
– Sushant Khurana
Jun 26 '12 at 12:00
@SushantKhurana@ For basic authorization just specify the username and password as the 4th and 5th parameters in the XMLHttpopen
method call.
– AnthonyWJones
Jun 26 '12 at 13:26
Thanks for the help Anthony.
– Sushant Khurana
Jul 18 '12 at 12:25
add a comment |
hey anthony! How would we specify auth keys or request arguments externally? or we can just keep that a part of the url.
– Sushant Khurana
Jun 26 '12 at 11:09
@SushantKhurana: The would depend on what the server is expecting. You an include additional headers in the request with addHeader method so if you have control of both ends you create some custom "x-myheader" header. Or you can use a "POST", add a Content-Type header like "application/x-www-form-urlencoded" and pass a urlencoded string contianing parameter to thesend
method. Or as you say include the values in the query string. It really depends on what you have available to you on the server.
– AnthonyWJones
Jun 26 '12 at 11:36
Yes. I have to do that via a Basic HTTP Authorization header only. Example Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
– Sushant Khurana
Jun 26 '12 at 12:00
@SushantKhurana@ For basic authorization just specify the username and password as the 4th and 5th parameters in the XMLHttpopen
method call.
– AnthonyWJones
Jun 26 '12 at 13:26
Thanks for the help Anthony.
– Sushant Khurana
Jul 18 '12 at 12:25
hey anthony! How would we specify auth keys or request arguments externally? or we can just keep that a part of the url.
– Sushant Khurana
Jun 26 '12 at 11:09
hey anthony! How would we specify auth keys or request arguments externally? or we can just keep that a part of the url.
– Sushant Khurana
Jun 26 '12 at 11:09
@SushantKhurana: The would depend on what the server is expecting. You an include additional headers in the request with addHeader method so if you have control of both ends you create some custom "x-myheader" header. Or you can use a "POST", add a Content-Type header like "application/x-www-form-urlencoded" and pass a urlencoded string contianing parameter to the
send
method. Or as you say include the values in the query string. It really depends on what you have available to you on the server.– AnthonyWJones
Jun 26 '12 at 11:36
@SushantKhurana: The would depend on what the server is expecting. You an include additional headers in the request with addHeader method so if you have control of both ends you create some custom "x-myheader" header. Or you can use a "POST", add a Content-Type header like "application/x-www-form-urlencoded" and pass a urlencoded string contianing parameter to the
send
method. Or as you say include the values in the query string. It really depends on what you have available to you on the server.– AnthonyWJones
Jun 26 '12 at 11:36
Yes. I have to do that via a Basic HTTP Authorization header only. Example Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
– Sushant Khurana
Jun 26 '12 at 12:00
Yes. I have to do that via a Basic HTTP Authorization header only. Example Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
– Sushant Khurana
Jun 26 '12 at 12:00
@SushantKhurana@ For basic authorization just specify the username and password as the 4th and 5th parameters in the XMLHttp
open
method call.– AnthonyWJones
Jun 26 '12 at 13:26
@SushantKhurana@ For basic authorization just specify the username and password as the 4th and 5th parameters in the XMLHttp
open
method call.– AnthonyWJones
Jun 26 '12 at 13:26
Thanks for the help Anthony.
– Sushant Khurana
Jul 18 '12 at 12:25
Thanks for the help Anthony.
– Sushant Khurana
Jul 18 '12 at 12:25
add a comment |
If you are using the GET request to actually SEND data...
check:
http://techhelplist.com/index.php/tech-tutorials/37-windows-troubles/60-vbscript-sending-get-request
The problem with MSXML2.XMLHTTP is that there are several versions of it, with different names depending on the windows os version and patches.
this explains it:
http://support.microsoft.com/kb/269238
i have had more luck using vbscript to call
set ID = CreateObject("InternetExplorer.Application")
IE.visible = 0
IE.navigate "http://example.com/parser.php?key=" & value & "key2=" & value2
do while IE.Busy....
....and more stuff but just to let the request go thru.
That is just ugly and inefficient, why would you do this? Every time you call this code you are creating an instance ofiexplore.exe
in the background which then calls winsock.dll to handle to the HTTP request, where as the Server HTTP Request objects do this directly with far less overhead.
– Lankymart
Jul 6 '16 at 9:33
add a comment |
If you are using the GET request to actually SEND data...
check:
http://techhelplist.com/index.php/tech-tutorials/37-windows-troubles/60-vbscript-sending-get-request
The problem with MSXML2.XMLHTTP is that there are several versions of it, with different names depending on the windows os version and patches.
this explains it:
http://support.microsoft.com/kb/269238
i have had more luck using vbscript to call
set ID = CreateObject("InternetExplorer.Application")
IE.visible = 0
IE.navigate "http://example.com/parser.php?key=" & value & "key2=" & value2
do while IE.Busy....
....and more stuff but just to let the request go thru.
That is just ugly and inefficient, why would you do this? Every time you call this code you are creating an instance ofiexplore.exe
in the background which then calls winsock.dll to handle to the HTTP request, where as the Server HTTP Request objects do this directly with far less overhead.
– Lankymart
Jul 6 '16 at 9:33
add a comment |
If you are using the GET request to actually SEND data...
check:
http://techhelplist.com/index.php/tech-tutorials/37-windows-troubles/60-vbscript-sending-get-request
The problem with MSXML2.XMLHTTP is that there are several versions of it, with different names depending on the windows os version and patches.
this explains it:
http://support.microsoft.com/kb/269238
i have had more luck using vbscript to call
set ID = CreateObject("InternetExplorer.Application")
IE.visible = 0
IE.navigate "http://example.com/parser.php?key=" & value & "key2=" & value2
do while IE.Busy....
....and more stuff but just to let the request go thru.
If you are using the GET request to actually SEND data...
check:
http://techhelplist.com/index.php/tech-tutorials/37-windows-troubles/60-vbscript-sending-get-request
The problem with MSXML2.XMLHTTP is that there are several versions of it, with different names depending on the windows os version and patches.
this explains it:
http://support.microsoft.com/kb/269238
i have had more luck using vbscript to call
set ID = CreateObject("InternetExplorer.Application")
IE.visible = 0
IE.navigate "http://example.com/parser.php?key=" & value & "key2=" & value2
do while IE.Busy....
....and more stuff but just to let the request go thru.
answered Feb 18 '12 at 4:12
JamieJamie
491
491
That is just ugly and inefficient, why would you do this? Every time you call this code you are creating an instance ofiexplore.exe
in the background which then calls winsock.dll to handle to the HTTP request, where as the Server HTTP Request objects do this directly with far less overhead.
– Lankymart
Jul 6 '16 at 9:33
add a comment |
That is just ugly and inefficient, why would you do this? Every time you call this code you are creating an instance ofiexplore.exe
in the background which then calls winsock.dll to handle to the HTTP request, where as the Server HTTP Request objects do this directly with far less overhead.
– Lankymart
Jul 6 '16 at 9:33
That is just ugly and inefficient, why would you do this? Every time you call this code you are creating an instance of
iexplore.exe
in the background which then calls winsock.dll to handle to the HTTP request, where as the Server HTTP Request objects do this directly with far less overhead.– Lankymart
Jul 6 '16 at 9:33
That is just ugly and inefficient, why would you do this? Every time you call this code you are creating an instance of
iexplore.exe
in the background which then calls winsock.dll to handle to the HTTP request, where as the Server HTTP Request objects do this directly with far less overhead.– Lankymart
Jul 6 '16 at 9:33
add a comment |
strRequest = "<soap:Envelope xmlns:soap=""http://www.w3.org/2003/05/soap-envelope"" " &_
"xmlns:tem=""http://tempuri.org/"">" &_
"<soap:Header/>" &_
"<soap:Body>" &_
"<tem:Authorization>" &_
"<tem:strCC>"&1234123412341234&"</tem:strCC>" &_
"<tem:strEXPMNTH>"&11&"</tem:strEXPMNTH>" &_
"<tem:CVV2>"&123&"</tem:CVV2>" &_
"<tem:strYR>"&23&"</tem:strYR>" &_
"<tem:dblAmount>"&1235&"</tem:dblAmount>" &_
"</tem:Authorization>" &_
"</soap:Body>" &_
"</soap:Envelope>"
EndPointLink = "http://www.trainingrite.net/trainingrite_epaysystem" &_
"/trainingrite_epaysystem/tr_epaysys.asmx"
dim http
set http=createObject("Microsoft.XMLHTTP")
http.open "POST",EndPointLink,false
http.setRequestHeader "Content-Type","text/xml"
msgbox "REQUEST : " & strRequest
http.send strRequest
If http.Status = 200 Then
'msgbox "RESPONSE : " & http.responseXML.xml
msgbox "RESPONSE : " & http.responseText
responseText=http.responseText
else
msgbox "ERRCODE : " & http.status
End If
Call ParseTag(responseText,"AuthorizationResult")
Call CreateXMLEvidence(responseText,strRequest)
'Function to fetch the required message from a TAG
Function ParseTag(ResponseXML,SearchTag)
ResponseMessage=split(split(split(ResponseXML,SearchTag)(1),"</")(0),">")(1)
Msgbox ResponseMessage
End Function
'Function to create XML test evidence files
Function CreateXMLEvidence(ResponseXML,strRequest)
Set fso=createobject("Scripting.FileSystemObject")
Set qfile=fso.CreateTextFile("C:UsersRajkumarJoshuaDesktopDCIMSampleResponse.xml",2)
Set qfile1=fso.CreateTextFile("C:UsersRajkumarJoshuaDesktopDCIMSampleReuest.xml",2)
qfile.write ResponseXML
qfile.close
qfile1.write strRequest
qfile1.close
End Function
You need to have some commenting to supplement your code.
– theblindprophet
Jun 14 '16 at 13:27
add a comment |
strRequest = "<soap:Envelope xmlns:soap=""http://www.w3.org/2003/05/soap-envelope"" " &_
"xmlns:tem=""http://tempuri.org/"">" &_
"<soap:Header/>" &_
"<soap:Body>" &_
"<tem:Authorization>" &_
"<tem:strCC>"&1234123412341234&"</tem:strCC>" &_
"<tem:strEXPMNTH>"&11&"</tem:strEXPMNTH>" &_
"<tem:CVV2>"&123&"</tem:CVV2>" &_
"<tem:strYR>"&23&"</tem:strYR>" &_
"<tem:dblAmount>"&1235&"</tem:dblAmount>" &_
"</tem:Authorization>" &_
"</soap:Body>" &_
"</soap:Envelope>"
EndPointLink = "http://www.trainingrite.net/trainingrite_epaysystem" &_
"/trainingrite_epaysystem/tr_epaysys.asmx"
dim http
set http=createObject("Microsoft.XMLHTTP")
http.open "POST",EndPointLink,false
http.setRequestHeader "Content-Type","text/xml"
msgbox "REQUEST : " & strRequest
http.send strRequest
If http.Status = 200 Then
'msgbox "RESPONSE : " & http.responseXML.xml
msgbox "RESPONSE : " & http.responseText
responseText=http.responseText
else
msgbox "ERRCODE : " & http.status
End If
Call ParseTag(responseText,"AuthorizationResult")
Call CreateXMLEvidence(responseText,strRequest)
'Function to fetch the required message from a TAG
Function ParseTag(ResponseXML,SearchTag)
ResponseMessage=split(split(split(ResponseXML,SearchTag)(1),"</")(0),">")(1)
Msgbox ResponseMessage
End Function
'Function to create XML test evidence files
Function CreateXMLEvidence(ResponseXML,strRequest)
Set fso=createobject("Scripting.FileSystemObject")
Set qfile=fso.CreateTextFile("C:UsersRajkumarJoshuaDesktopDCIMSampleResponse.xml",2)
Set qfile1=fso.CreateTextFile("C:UsersRajkumarJoshuaDesktopDCIMSampleReuest.xml",2)
qfile.write ResponseXML
qfile.close
qfile1.write strRequest
qfile1.close
End Function
You need to have some commenting to supplement your code.
– theblindprophet
Jun 14 '16 at 13:27
add a comment |
strRequest = "<soap:Envelope xmlns:soap=""http://www.w3.org/2003/05/soap-envelope"" " &_
"xmlns:tem=""http://tempuri.org/"">" &_
"<soap:Header/>" &_
"<soap:Body>" &_
"<tem:Authorization>" &_
"<tem:strCC>"&1234123412341234&"</tem:strCC>" &_
"<tem:strEXPMNTH>"&11&"</tem:strEXPMNTH>" &_
"<tem:CVV2>"&123&"</tem:CVV2>" &_
"<tem:strYR>"&23&"</tem:strYR>" &_
"<tem:dblAmount>"&1235&"</tem:dblAmount>" &_
"</tem:Authorization>" &_
"</soap:Body>" &_
"</soap:Envelope>"
EndPointLink = "http://www.trainingrite.net/trainingrite_epaysystem" &_
"/trainingrite_epaysystem/tr_epaysys.asmx"
dim http
set http=createObject("Microsoft.XMLHTTP")
http.open "POST",EndPointLink,false
http.setRequestHeader "Content-Type","text/xml"
msgbox "REQUEST : " & strRequest
http.send strRequest
If http.Status = 200 Then
'msgbox "RESPONSE : " & http.responseXML.xml
msgbox "RESPONSE : " & http.responseText
responseText=http.responseText
else
msgbox "ERRCODE : " & http.status
End If
Call ParseTag(responseText,"AuthorizationResult")
Call CreateXMLEvidence(responseText,strRequest)
'Function to fetch the required message from a TAG
Function ParseTag(ResponseXML,SearchTag)
ResponseMessage=split(split(split(ResponseXML,SearchTag)(1),"</")(0),">")(1)
Msgbox ResponseMessage
End Function
'Function to create XML test evidence files
Function CreateXMLEvidence(ResponseXML,strRequest)
Set fso=createobject("Scripting.FileSystemObject")
Set qfile=fso.CreateTextFile("C:UsersRajkumarJoshuaDesktopDCIMSampleResponse.xml",2)
Set qfile1=fso.CreateTextFile("C:UsersRajkumarJoshuaDesktopDCIMSampleReuest.xml",2)
qfile.write ResponseXML
qfile.close
qfile1.write strRequest
qfile1.close
End Function
strRequest = "<soap:Envelope xmlns:soap=""http://www.w3.org/2003/05/soap-envelope"" " &_
"xmlns:tem=""http://tempuri.org/"">" &_
"<soap:Header/>" &_
"<soap:Body>" &_
"<tem:Authorization>" &_
"<tem:strCC>"&1234123412341234&"</tem:strCC>" &_
"<tem:strEXPMNTH>"&11&"</tem:strEXPMNTH>" &_
"<tem:CVV2>"&123&"</tem:CVV2>" &_
"<tem:strYR>"&23&"</tem:strYR>" &_
"<tem:dblAmount>"&1235&"</tem:dblAmount>" &_
"</tem:Authorization>" &_
"</soap:Body>" &_
"</soap:Envelope>"
EndPointLink = "http://www.trainingrite.net/trainingrite_epaysystem" &_
"/trainingrite_epaysystem/tr_epaysys.asmx"
dim http
set http=createObject("Microsoft.XMLHTTP")
http.open "POST",EndPointLink,false
http.setRequestHeader "Content-Type","text/xml"
msgbox "REQUEST : " & strRequest
http.send strRequest
If http.Status = 200 Then
'msgbox "RESPONSE : " & http.responseXML.xml
msgbox "RESPONSE : " & http.responseText
responseText=http.responseText
else
msgbox "ERRCODE : " & http.status
End If
Call ParseTag(responseText,"AuthorizationResult")
Call CreateXMLEvidence(responseText,strRequest)
'Function to fetch the required message from a TAG
Function ParseTag(ResponseXML,SearchTag)
ResponseMessage=split(split(split(ResponseXML,SearchTag)(1),"</")(0),">")(1)
Msgbox ResponseMessage
End Function
'Function to create XML test evidence files
Function CreateXMLEvidence(ResponseXML,strRequest)
Set fso=createobject("Scripting.FileSystemObject")
Set qfile=fso.CreateTextFile("C:UsersRajkumarJoshuaDesktopDCIMSampleResponse.xml",2)
Set qfile1=fso.CreateTextFile("C:UsersRajkumarJoshuaDesktopDCIMSampleReuest.xml",2)
qfile.write ResponseXML
qfile.close
qfile1.write strRequest
qfile1.close
End Function
answered Jun 14 '16 at 13:08
Rajkumar Joshua MRajkumar Joshua M
71
71
You need to have some commenting to supplement your code.
– theblindprophet
Jun 14 '16 at 13:27
add a comment |
You need to have some commenting to supplement your code.
– theblindprophet
Jun 14 '16 at 13:27
You need to have some commenting to supplement your code.
– theblindprophet
Jun 14 '16 at 13:27
You need to have some commenting to supplement your code.
– theblindprophet
Jun 14 '16 at 13:27
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f204759%2fhttp-get-in-vbs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown