Solved

How To Post From A Script

Posted on 2004-03-23
3
461 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Query not working correctly? (or how i want it to... 6 54
Validating Date Part2 2 28
2012 SQL to JSON Select 5 32
SQL Query Returns Records in SSMS but not Classic ASP 5 26
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…
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/…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

730 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