Solved

How To Post From A Script

Posted on 2004-03-23
3
453 Views
Last Modified: 2010-07-27
I need to post some XML to an external web address (Java servlet on another web server) from within a shopping cart written in aspl. I need example code for how to do this. I also need to know if it can be done to an SSL address.
0
Comment
Question by:jimkat
3 Comments
 
LVL 21

Expert Comment

by:ap_sajith
ID: 10665171
Have you looked into XMLHTTP as an option?. You can use XMLHTTP to send an XML stream to the other server and recieve the output from the other server.

eg:

Dim xmlhttp
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
'Open a connection and send a request to the server in the form of an XML fragment
xmlhttp.Open("POST", "http://www.yourserver.com/yourpage.asp", False)
xmlhttp.send("<reqtimesheet user='jimbob'/>")
Response.WRite Cmlhttp.ResponseText ' ** Use ResponseXML if an XML stream is returned **

Check out these articles for further info..

http://www.15seconds.com/issue/991125.htm
http://www.eggheadcafe.com/articles/20010209.asp

Cheers!!
0
 
LVL 28

Accepted Solution

by:
sybe earned 500 total points
ID: 10665642
Function PostToUrl(url,data)
    Dim oXMLHttpRequest
    Set oXMLHttpRequest = Server.CreateObject("Microsoft.XMLHTTP")
    oXMLHttpRequest.Open "POST", url, False
    oXMLHttpRequest.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    oXMLHttpRequest.Send data
    PostToUrl = oXMLHttpRequest.responseText
    Set oXMLHttpRequest = Nothing
End Function
0
 
LVL 8

Expert Comment

by:fozylet
ID: 10665725
If it is SOAP...

function GetSendSoapResponse(strMessage,strURL,strAction)
      ' must create an XML document to format the request message
      Dim xmlhttp, strSoap
      Set xmlhttp = Server.CreateObject("Msxml2.ServerXMLHTTP")

      ' Build the XML/SOAP request message
      strSoap = strMessage
      ' Send the request to the server
      xmlhttp.Open "POST", strURL, False
      xmlhttp.setRequestHeader "Man", "POST " & strURL & " HTTP/1.1"
      xmlhttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
      xmlhttp.setRequestHeader "SOAPAction", strAction

      'send the request to the webservice
      xmlhttp.send(strSoap)

      If xmlhttp.Status = 200 Then 'if response code is OK
      GetSendSoapResponse = xmlhttp.responseText
      Else 'an error has occurred
      GetSendSoapResponse = ""
      Response.Write("Web service Server Error...<br>")
      Response.Write("status = " & xmlhttp.status)
      Response.Write("<br>" & xmlhttp.statusText)
      Response.Write("<br><pre>" & Request.ServerVariables("ALL_HTTP") & "</pre>")
      End If
      Set xmlhttp = nothing
end function
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now