Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 445
  • Last Modified:

Get contents from other web site

I need to get contents from other web site a display it on the screen.  I have the following code:

dim url, xmlhttp
    url = "http://www.cpms.osd.mil/WageData/wagedata"
    set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
     xmlhttp.open "GET", url, false
    xmlhttp.setRequestHeader "Content-Type", "text/HTML"
   xmlhttp.Send
   
        Response.write (xmlhttp.responseText)
    set xmlhttp = nothing


I'm getting this error:

We have encountered an error on this page.  
 
An 500;100 ASP Error encountered.

Error (-2147012867): A connection with the server could not be established
 
It looks like it's because the firewall.  Is there a way to get around it or if there's another way to display data from other web page?

Thanks,
0
ttta83
Asked:
ttta83
  • 4
  • 4
1 Solution
 
Rainer JeschorCommented:
Hi,
I think this is not the connection/firewall because you get a response - an IIS error 500.
What happens if you copy that URL and open e.g. Internet Explorer on the server where you host your ASP web site and open that url? You probably should get the same result.
Is there a difference when you open that url in your local browser?
0
 
Scott Fell, EE MVEDeveloperCommented:
Are you sure this is on your server? MSXML2.ServerXMLHTTP.6.0

Try

url="http://www.cpms.osd.mil/WageData/wagedata"
 Set xmlHttp =  Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
    xmlHttp.Open "GET", url, False
    xmlHttp.setRequestHeader "User-Agent", "asp httprequest"
    xmlHttp.setRequestHeader "content-type", "application/x-www-form-urlencoded"
    xmlHttp.Send
    getHTML = xmlHttp.responseText
  set xmlHttp = Nothing
response.write getHtml

Open in new window

or
url="http://www.cpms.osd.mil/WageData/wagedata"
 Set xmlHttp =  Server.CreateObject("MSXML2.ServerXMLHTTP")
    xmlHttp.Open "GET", url, False
    xmlHttp.setRequestHeader "User-Agent", "asp httprequest"
    xmlHttp.setRequestHeader "content-type", "application/x-www-form-urlencoded"
    xmlHttp.Send
    getHTML = xmlHttp.responseText
  set xmlHttp = Nothing
response.write getHtml

Open in new window

0
 
ttta83Author Commented:
Rainer Jeschor,

I got "The page cannot be displayed" when I tried to open the URL in IE on the server.  It works fine in my local browser.
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!

 
ttta83Author Commented:
Scott Fell,

I checked regedit and MSXML2.ServerXMLHTTP.6.0 is on the server.

I tried both of your examples and got the same error:

     An 500;100 ASP Error encountered.
     Error (-2147012867): A connection with the server could not be established

I tried them on different web and got this:

     msxml3.dll error '80072efd'
     A connection with the server could not be established

However both work in my personal web (host by GoDaddy).  

Thanks,
0
 
Scott Fell, EE MVEDeveloperCommented:
I just tested this on my server and it worked.

if it is not working, are you sure classic asp is turned on?

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Dim aRequest
Set aRequest = CreateObject ("Microsoft.XMLHTTP")
aRequest.Open "GET","http://www.cpms.osd.mil/WageData/wagedata",False
aRequest.Send
response.write aRequest.responseText
%>

Open in new window

0
 
ttta83Author Commented:
Scott,

I tested your latest code on the server and got:

  msxml3.dll error '800c0005'
  The system cannot locate the resource specified.

Does it have anything to do with the firewall in my company?  Is there another way to get data from other web page?

Thanks for your help!.
0
 
Scott Fell, EE MVEDeveloperCommented:
Firewalls and networking is not my expertise.

In a pinch you can frame it.

<style>
iframe{
   width:600px;
   height:500px;
}
</style>
<!-- place below in your body section and style tags in your head section -->
<iframe src="http://www.cpms.osd.mil/WageData/wagedata">Frames are not supported</iframe>

Open in new window

0
 
ttta83Author Commented:
Scott,

The problem is the firewall setting.  

I added the line below and the network team added the exception rule for it to work.

     xmlHttp.setProxy 2, "http=ourdomain:portnumber", ""

Thank you very much for your help!
0
 
Scott Fell, EE MVEDeveloperCommented:
Thank you for the update.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now