Solved

Get contents from other web site

Posted on 2014-01-23
9
432 Views
Last Modified: 2014-02-05
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
Comment
Question by:ttta83
  • 4
  • 4
9 Comments
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 39805101
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
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39805422
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
 

Author Comment

by:ttta83
ID: 39806618
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
 

Author Comment

by:ttta83
ID: 39806627
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39806662
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
 

Author Comment

by:ttta83
ID: 39806764
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
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39806816
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
 

Author Comment

by:ttta83
ID: 39837264
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
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39837516
Thank you for the update.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now