Pass XML Request String via HTTP POST Question

M

Matt

Here's the VB routine that I tried to send the XML request to an ASP page
(aspxml.asp).
The code has no error, but the aspxml.asp cannot see the string

Sub sendXMLRequest()
Dim HttpReq As New MSXML2.XMLHTTP
Dim voidReqXML As String
voidReqXML = "<Customers><Name>Joe</Name></Customer>"
'sending XML requests via HTTP
HttpReq.Open "POST", "http://localhost/aspxml.asp", False
HttpReq.send voidReqXML
End Sub

//aspxml.asp
<%= Request.Form %>

Any ideas??
 
A

Aaron Bertrand [MVP]

You forgot

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

See http://www.aspfaq.com/2173 for code samples, including the better ProgID
to use.

(PS this looks suspiciously like VB code, not ASP code. Why is that?)
 
M

Matt

Thanks Aaron!

<%
url = "http://localhost/aspxml.asp"
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "POST", url, false
xmlhttp.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
xmlhttp.send "x=1&y=2"
Response.write xmlhttp.responseText
set xmlhttp = nothing
%>

I used the example, and I thought the above code will post the data to
http://localhost/aspxml.asp
And if aspxml.asp has <%= Request.Form %>, then it should get data
"x=1&y=2".

But when i open http://localhost/aspxml.asp in the browser, i couldn't see
the data.

I think I miss something, and misunderstand something, please advise.
Thanks!
 
A

Aaron Bertrand - MVP

Well, of course not. How will aspxml.asp know of x=1&y=2 unless you hit the
ASP page that contains the ASP code you've displayed here?

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,824
Latest member
Nater888

Latest Threads

Top