Post XML Https help PLEASE!

D

DavidT

I need to build a valid XML file using ASP form elements, pass that "file"
to a https url and then retrieve the ID that is returned. I can build the
XML into a string no problem but how then heck do I go about
posting/retrieving?

I've come across something like this in my search:

Dim oXML, sURL
Dim sContents
sURL = "https://domain/page.asp"
Set oXML = CreateObject("MSXML2.ServerXMLHTTP")
oXML.Open "POST", sURL, False
oXML.SetRequestHeader "Content-Type","application/x-www-form-urlencoded"
oXML.Send "txtUsername=Anthony&txtPassword=abcdefghi"
GetPostResponse = oXML.responseText
Set oXML = Nothing

But where would my XML string to post fit into this?

Driving me nutters. Any help is appreciated.

Thanks

David
 
A

Aaron [SQL Server MVP]

oXML.Send "txtUsername=Anthony&txtPassword=abcdefghi"
GetPostResponse = oXML.responseText
Set oXML = Nothing

But where would my XML string to post fit into this?

Have you tried

oXML.Send
"txtUsername=Anthony&txtPassword=abcdefghi&xmlDataVariableName=" & xmlData

? How is page.asp expecting to receive the XML data?

A
 
J

Jeff Cochran

I need to build a valid XML file using ASP form elements, pass that "file"
to a https url and then retrieve the ID that is returned. I can build the
XML into a string no problem but how then heck do I go about
posting/retrieving?

I've come across something like this in my search:

Dim oXML, sURL
Dim sContents
sURL = "https://domain/page.asp"
Set oXML = CreateObject("MSXML2.ServerXMLHTTP")
oXML.Open "POST", sURL, False
oXML.SetRequestHeader "Content-Type","application/x-www-form-urlencoded"
oXML.Send "txtUsername=Anthony&txtPassword=abcdefghi"
GetPostResponse = oXML.responseText
Set oXML = Nothing

But where would my XML string to post fit into this?

oXML.Send YourXMLStringVariable

Jeff
 
D

DavidT

Thanks Both.

Page.asp is expecting preformated valid XML. I have a spec for that so I'm
not to concerned. Sending via XML is new to me. I'm used to just setting up
the DSN(less) connection and putting things directly into a db.

Can I do multuple sends?
oXML.Send "txtUsername=Anthony&txtPassword=abcdefghi"
oXML.Send strXML
 
J

Jeff Cochran

Thanks Both.

Page.asp is expecting preformated valid XML. I have a spec for that so I'm
not to concerned. Sending via XML is new to me. I'm used to just setting up
the DSN(less) connection and putting things directly into a db.

Can I do multuple sends?
oXML.Send "txtUsername=Anthony&txtPassword=abcdefghi"
oXML.Send strXML

Haven't tried. I usually build the string then send it, but I'm doing
small amounts of XML. You could find out with a quick test of course.

Jeff
 
D

DavidT

Thanks to all. I managed to get this to work. My solution was:

Dim strXMLFile,objXml,ObjHTTP

Set objXml= Server.CreateObject("Microsoft.XMLDOM")
Set ObjHTTP = Server.CreateObject("MSXML2.XMLHTTP")

objXml.loadxml strXML

If objXML.parseError.errorCode = 0 Then

ObjHTTP.open "POST",
"https://www.trandotcom.com/LoanManager/QuickApp/QuickPost.ASPX", false
ObjHTTP.setRequestHeader "Content-type", "application/xml"
ObjHTTP.send strXML
Response.Write(ObjHTTP.responseText)
Else
Response.Write(objXML.parseError.errorCode &
objXML.parseError.reason)
End If

Thanks again
 

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,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top