Solved

Is there an ASP equivalent for cfhttp?

Posted on 2013-02-06
8
726 Views
Last Modified: 2013-02-06
I have a Coldfusion page I am converting to ASP.

What would be the syntax for ASP for this?

<cfhttp url="#cgiConnector#" method="get">
<cfhttpparam type="Header" name="Accept-Encoding" value="deflate;q=0">
<cfhttpparam type="Header" name="TE" value="deflate;q=0">
</cfhttp>

Is there an ASP equivalent for cfhttp?
0
Comment
Question by:Donnie Walker
[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
  • 4
  • 4
8 Comments
 
LVL 33

Expert Comment

by:Big Monty
ID: 38859898
This should get you what you want. PostData is the data you want to send over.

Set ServerXmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
ServerXmlHttp.open "POST", "http://www.domain.com/page.asp"
ServerXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
ServerXlHttp.setRequestHeader "Content-Length", Len(PostData)
ServerXmlHttp.send PostData
0
 

Author Comment

by:Donnie Walker
ID: 38859925
Is this for Classic ASP?

How do I get the response back from http://www.domain.com/page.asp?
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 38859945
yup, this is for classic asp. To get the response back, you would use the ResponseText (assuming you're expecting plain text back, if not I included the property to use for xml)  property of the ServerXmlHttp object:

Set ServerXmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
ServerXmlHttp.open "POST", "http://www.domain.com/page.asp"
ServerXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
ServerXlHttp.setRequestHeader "Content-Length", Len(PostData)
ServerXmlHttp.send PostData

If ServerXmlHttp.status = 200 Then
      TextResponse = ServerXmlHttp.responseText
      XMLResponse = ServerXmlHttp.responseXML
Else
      ' Handle missing response or other errors here
End If

Set ServerXmlHttp = Nothing
0
Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

 

Author Comment

by:Donnie Walker
ID: 38860012
ok, so if the ServerXmlHttp.status is 200 then that is an error?

Then if the response back is a url then the else would be this:

      response.redirect ServerXmlHttp.responseText
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 38860037
a status of 200 means NO error has occured, it's basically a check to make sure everything worked properly on the remote servers end.

You could do the redirect as you have above, but I would assign the responseText to a variable, close and destroy all of your objects, THEN do the redirect. This ensures no unneeded objects remain in memory before you go to another page.
0
 

Author Comment

by:Donnie Walker
ID: 38860682
When I do this:

Set ServerXmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
ServerXmlHttp.open "POST", "https://e5.onthehub.com/WebStore/Security/AuthenticateUser.aspx?username=dw100&email=dw100@college.edu&key=85515708&shopper_ip=10.1.1.117&last_name=Doe&first_name=John&academic_statuses=staff,students,faculty"
ServerXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
ServerXlHttp.setRequestHeader "Content-Length", Len(PostData)
ServerXmlHttp.send PostData

If ServerXmlHttp.status = 200 Then
      TextResponse = ServerXmlHttp.responseText
      XMLResponse = ServerXmlHttp.responseXML
      response.redirect ServerXmlHttp.responseText
End If

Set ServerXmlHttp = Nothing

I get this error:

Microsoft VBScript runtime error '800a01a8'

Object required: ''

The error is on line:
ServerXlHttp.setRequestHeader "Content-Length", Len(PostData)
0
 
LVL 33

Accepted Solution

by:
Big Monty earned 500 total points
ID: 38860838
you have a typo in between the x and l :)

should be:

ServerXmlHttp.setRequestHeader "Content-Length", Len(PostData)
0
 

Author Closing Comment

by:Donnie Walker
ID: 38860916
Thanks!
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

705 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