Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Is there an ASP equivalent for cfhttp?

Posted on 2013-02-06
8
Medium Priority
?
741 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 34

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 34

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 34

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 34

Accepted Solution

by:
Big Monty earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
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/…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

610 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