Solved

Is there an ASP equivalent for cfhttp?

Posted on 2013-02-06
8
720 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
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 

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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Obtaining data on ASP 8 41
Code Manager | Snippits 2 88
ASP and Extracting XML 7 42
Get Pop-Up Or Div Info Box From JQuery DataTable Cell in ASP 7 31
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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

742 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