VBScript - XML HTTP Post
'=============================================================
' NAME: XMLPost.vbs
' AUTHOR: Neal Walters
' DATE : 3/26/2005
' http://VBScript-Training.com
'=============================================================
Dim xmlHttp
Dim doc
Dim strQuery
Dim strURL
Dim strPostBody
Dim xmlFileName
'allow drag/drop of filename onto this VB/Script
if WScript.Arguments.Count > 0 then
xmlFileName = WScript.Arguments(0)
else
xmlFileName = "D:\Vish\Altura\XML\CC71628_0309052202_4items.xml"
xmlFileName = "D:\Vish\Altura\XML\CC71628_0309052202_4items_TestCreditCard.xml"
end if
set xmlHttp = CreateObject("Microsoft.xmlHttp")
set doc = CreateObject("MSXML2.DOMDocument")
' Validate the document using the MSXML parser.
doc.load (xmlFileName)
If doc.parseError.errorCode Then
' Do something with the error.
Wscript.Echo "Parse Error: " & vbcrlf & _
" Reason = " & doc.parseError.reason & vbcrlf & _
" Line = " & doc.parseError.line & vbcrlf & _
" linePos = " & doc.parseError.linePos & vbcrlf & _
" srcText = " & doc.parseError.srcText & vbcrlf & _
" ErrorCode = " & doc.parseError.ErrorCode & vbcrlf
WScript.quit
'else
' WScript.Echo doc.xml
End If
' Post the template.
'on error resume next
isAsynCall = False
sendData ="data=" & doc.xml
xmlHttp.Open "POST", "http://corpdev/Odimo.Altura.Webservices.Order/orderReceive.asmx/submit", isAsynCall
'xmlHttp.setRequestHeader "Content-type", "application/xml"
xmlHttp.setRequestHeader "Content-type","application/x-www-form-urlencoded"
xmlHttp.setRequestHeader "Content-Length",len(sendData)
xmlHttp.send sendData
' Retrieve the results.
'WScript.Echo doc.xml & vbcrlf
WScript.Echo " ResponseText=" & xmlHttp.responseText & _
" Status=" & xmlHttp.status & _
" text=" & xmlHttp.statusText
'Wscript.echo err.number & "desc=" & err.description
WScript.Echo "The end"
|