?
Solved

Google XML with asp not working (but was...!)

Posted on 2012-08-26
9
Medium Priority
?
760 Views
Last Modified: 2012-08-26
Hello Experts,

This page was working fine, however, I now receive an error, which seems to be very strange!

The following link shows the error: https://cws14.my-hosting-panel.com/villas/_admin/searchaddress.asp?address=Kaschechawan PQ Airport (ZKE), Canada&ID=1636

The code of the page is here:

<?xml version="1.0" encoding="ISO-8859-1"?>
<%@LANGUAGE="VBSCRIPT"%>

<%
If Request.QueryString("ID") <> "" then
session("LocationID") = Request.QueryString("ID")
end if
If request.form("searchagain") <> "" then
response.redirect("searchaddress.asp?address=" & request.form("address") & "&ID=" & Session("LocationID"))
end if
  Set objSrvHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP.6.0")
  Set objXMLSend = Server.CreateObject("Msxml2.DOMDocument.6.0")
  Set objXMLReceive = Server.CreateObject("Msxml2.DOMDocument.6.0")

   objXMLSend.async = false
   objXMLSend.loadXML ("*")
   
   url = "http://maps.google.com/maps/api/geocode/xml?address="
   address = request.querystring("address")
   sensor = "&sensor=false"
   url = url & address & sensor
   
   objSrvHTTP.open "GET", url, false
   objSrvHTTP.send (objXMLSend)
   Set objXML = objSrvHTTP.responseXML
   Response.ContentType = "text/xml"
   'Response.Write (objXMLReceive.xml)
   
   If objXML.parseError.errorCode <> 0 Then
	 response.write("Error Found")
   End If

 Set objLst = objXML.getElementsByTagName("*")

j = 0
i = 0
AddressStr = ""
AddStrLinkBack = ""

 For i = 0 to (objLst.length - 1)
	If objLst.item(i).nodeName = "lat" then
	lat = objLst.item(i).text
	end if
	If objLst.item(i).nodeName = "lng" then
	lng = objLst.item(i).text
	end if
    If objLst.item(i).nodeName = "formatted_address" Then
      AddressStr = objLst.item(i).text
	  j = j + 1
	  url = "searchaddress.asp?address=" & objLst.item(i).text
	  AddStrLinkBack = AddStrLinkBack & "<BR>&nbsp;<BR><a href=""" & url & """>" & objLst.item(i).text & " lng: " & lng & " lat: " & lat & "</a>"
    End If
 Next
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-32" />
<title>Searching Address</title>
</head>
<body>
<form name="form1" method="post">
<%
response.write(address & "<BR>")
If j = 1 then
response.redirect("confirmaddress.asp?lng=" & lng & "&lat=" & lat & "&address=" & AddressStr & "&view=" & request.QueryString("view") & "&ID=" & session("LocationID"))
else
	if J = 0 then
	response.write("Sorry - the address you entered could not be found.  Please amend and retry:<BR>&nbsp;<BR><input type=""text"" size=""50"" name=""address"" id=""address"" value=""" & request.querystring("address") & """ /><input type=""submit"" id=""searchagain"" name=""searchagain"" value=""Search Again"" />")
	else
	response.write("The address you requested returned multiple possibilities:<BR>&nbsp;<BR>" & AddStrLinkBack & "If the address is not listed, please try again, perhaps adding in more information:<BR>&nbsp;<BR><input type=""text"" size=""50"" name=""address"" id=""address"" value=""" & request.querystring("address") & """ /><input type=""submit"" id=""searchagain"" name=""searchagain"" value=""Search Again"" />")
	end if
End if
%>
</form>
</body>
</html>

Open in new window


Please help!  Thanks in advance!
0
Comment
Question by:Nico2011
  • 4
  • 4
8 Comments
 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 38334051
Google has change their tos and you may need to register  your application.  code.google.com/apis/console/
0
 
LVL 54

Accepted Solution

by:
Scott Fell,  EE MVE earned 2000 total points
ID: 38334066
Your link to the sample is using https but the code inside uses http.   Try changing all your links in your code so that https is being used such as

url = "http://maps.google.com/maps/api/geocode/xml?address="

to

url = "https://maps.google.com/maps/api/geocode/xml?address="

Or change your test link to http instead of https.
0
 

Author Comment

by:Nico2011
ID: 38334071
Thanks but it's not that - I've just been through their documentation.

I did however find the problem, which is that it doesn't like running through SSL!  If I switch SSL off for that page, it runs fine!
0
Independent Software Vendors: 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:Nico2011
ID: 38334130
I've requested that this question be closed as follows:

Accepted answer: 0 points for Nico2011's comment #a38334071

for the following reason:

I found the solution as I realised that the difference was that the new page was running under SSL
0
 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 38334131
Or change your test link to http instead of https.
Not running under ssl was my suggestion.
0
 

Author Comment

by:Nico2011
ID: 38334151
We must have been writing the same solution at the same time - your second solution is correct, but I didn't see it when I closed the question - not sure how that happened.

How can I post the points to you please?
0
 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 38334178
I'm not sure. If you don't see it on this thread, maybe request attention.
0
 

Author Closing Comment

by:Nico2011
ID: 38334252
Thank you
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Loops Section Overview
Suggested Courses

862 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