Solved

How To Post From A Script

Posted on 2004-03-23
3
450 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

24 Experts available now in Live!

Get 1:1 Help Now