Hi,
I have simulated my requirement by creating a web page that posts the data to the server and verified HTTP headers sent by the browser. The browser used the content-type as application/x-www-form-urlencoded and the XML file content also encoded to URL format, which I was not doing in my code. Following code worked fine for my requirement.
Code:Dim strResponse, xmlhttp, xmlDom, returnVal Dim strMessage Set xmlhttp = CreateObject("Microsoft.XMLHTTP") xmlhttp.open "POST", "http://mysite.com?environmentId=Development", false xmlhttp.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded" xmlhttp.SetRequestHeader "Accept", "image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, */*" xmlhttp.SetRequestHeader "Accept-Language", "en-us" xmlhttp.SetRequestHeader "Accept-Encoding", "gzip, deflate" 'Send the request synchronously by converting the encoding the message to be sent xmlhttp.send "message=" & escape(strMessage) 'If the state of the request is 4 then get the response and parse it If xmlhttp.readyState = 4 Then 'Get the response and set it to a string strResponse = xmlhttp.responseText 'Create DOM object reference and parse the xml string Set xmlDom = CreateObject("Msxml2.DOMDocument") xmlDom.loadxml(strResponse) 'Echo if any error while parsing If xmlDom.parseerror.errorcode <> 0 Then Wscript.echo "Reason for the error:" & xmlDom.parseerror.reason Else retVal = xmlDom.text Wscript.echo "Reason for the error:" & retVal End If End If
Thank you,
Raghu




Reply With Quote