Solved

coldfusion xml 500 internal server error

Posted on 2013-05-24
32
1,000 Views
Last Modified: 2013-05-24
Back into some web stuff after about 5 years. Trying to setup a basic xml parse in CF. Geeting a 500 internal server error. Windows 2008 and IIS.

I signed up for the Weather Underground API - I blocked out my API key. IIS is returning a 500 internal server error. ANy ideas??

<cfhttp url="http://api.wunderground.com/api/MyKeyGoesHere/geolookup/conditions/q/IA/07204.xml" method="get">
     <cfhttpparam type="header" name="Accept-Encoding" value="*" />
     <cfhttpparam type="Header" name="TE" value="deflate;q=0">
 </cfhttp>
      <cfset objRSS = xmlParse(cfhttp.filecontent)>
    <CFDUMP var="#objRSS#">
0
Comment
Question by:cb_it
  • 14
  • 12
  • 6
32 Comments
 
LVL 15

Expert Comment

by:Tomarse111
ID: 39194344
You can turn IIS to show detailed errors:

Click the site > Error Pages > Edit Feature settings (on the far right) > Check details errors.

The error is probably the CFHTTP is not returning valid XML in the XMLParse. Try dumping out the cfhttp.filecontent and aborting. Then see what is actually being returned.

Tom
0
 

Author Comment

by:cb_it
ID: 39194363
Thanks for the quick reply. I've been away from IIS WAY too long! I turned on the detailed errors.

An error occured while Parsing an XML document.  
Content is not allowed in prolog.  

I did put this xml url into my browser and it does return what looks like a valid xml file.
0
 
LVL 15

Expert Comment

by:Tomarse111
ID: 39194379
ok, so the FileContent being returned cannot yet be used in XMLParse() as its not valid.

Could you please do a dump of the FileConent and either screenshot it or copy it here?

or even better share the URL where its happening (if possible)

Tom
0
 
LVL 15

Expert Comment

by:Tomarse111
ID: 39194389
Try this little experiment as well from Ben Nadel:

http://www.bennadel.com/blog/1206-Content-Is-Not-Allowed-In-Prolog-ColdFusion-XML-And-The-Byte-Order-Mark-BOM-.htm

This has cropped more than once in my experience with XML and CF. This has sometimes helped.

Tom
0
 

Author Comment

by:cb_it
ID: 39194394
Funny, I have that page open in a tab right now! Will try and post back, thanks.
0
 

Author Comment

by:cb_it
ID: 39194409
Might be something on their end as I did a dump and got a connection error

ErrorDetail Connect Exception: Connection to http://api.wunderground.com refused  
Filecontent Connection Failure  

hmmm
0
 

Author Comment

by:cb_it
ID: 39194424
I paste in my xml url into a browser and get this (only partial copy/paste below)


- <response>
  <version>0.1</version>
  <termsofService>http://www.wunderground.com/weather/api/d/terms.html</termsofService>
- <features>
  <feature>geolookup</feature>
  <feature>conditions</feature>
  </features>
- <location>
  <type>CITY</type>
  <country>US</country>
  <country_iso3166>US</country_iso3166>
  <country_name>USA</country_name>
  <state>NJ</state>
  <city>Roselle Park</city>
  <tz_short>EDT</tz_short>
  <tz_long>America/New_York</tz_long>
  <lat>40.66550446</lat>
  <lon>-74.26724243</lon>
  <zip>07204</zip>
  <magic>1</magic>
  <wmo>99999</wmo>
  <l>/q/zmw:07204.1.99999</l>
  <requesturl>US/NJ/Roselle_Park.html</requesturl>
  <wuiurl>http://www.wunderground.com/US/NJ/Roselle_Park.html</wuiurl>
- <nearby_weather_stations>
- <airport>
- <station>
  <city>Linden</city>
  <state>NJ</state>
  <country>US</country>
  <icao>KLDJ</icao>
  <lat>40.61999893</lat>
  <lon>-74.23999786</lon>
  </station>
- <station>
  <city>Newark</city>
  <state>NJ</state>
  <country>US</country>
  <icao>KEWR</icao>
0
 
LVL 15

Expert Comment

by:Tomarse111
ID: 39194455
Hmm possibly their end then. If you could paste the entire XML you have into a text file and attach it here, then we can run it locally and see what it comes up with.

I would hazard a guess its a potential connection problem their end though
0
 
LVL 15

Expert Comment

by:Tomarse111
ID: 39194470
hmmm weird I just signed, used my key and your code above and it worked fine?

XMLParse worked perfectly?

Have you definitely signed up for the XML key and not a JSON key? (I don't know if these are seperate)
0
 

Author Comment

by:cb_it
ID: 39194494
Format is JSON or XML.

http://www.wunderground.com/weather/api/d/docs?d=data/index

I'm stumped. Works for you and not me!!
0
 

Author Comment

by:cb_it
ID: 39194502
I copy/paste their coldfusion json sample from here and get the following error

JSON parsing failure at character 1:'C' in Connection Failure



http://www.wunderground.com/weather/api/d/docs?d=resources/code-samples
0
 
LVL 15

Expert Comment

by:Tomarse111
ID: 39194514
What version of CF are you using?
0
 
LVL 15

Expert Comment

by:Tomarse111
ID: 39194530
I get the same problem with the JSON method; if you dump the cfhttp.filecontent, you get "Connection Failure" .. so guess that's not working. The XML version still is though.

Silly question but you have put your API key in your code above??
0
 

Author Comment

by:cb_it
ID: 39194531
ColdFusion 10,282462
0
 

Author Comment

by:cb_it
ID: 39194540
0
 
LVL 15

Expert Comment

by:Tomarse111
ID: 39194573
Yep that works for me as well. This page is using your code:

http://www.orangecactus.co.uk/admin/test.cfm

The code:

http://pastebin.com/psy13zyB

Tom
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:cb_it
ID: 39194580
Grrr, thanks for the help. Could be a firewall issue??
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39194584
Edit Oops... I missed a few responses ;-)  Yes, since it seems connection related it's possible there's a firewall problem.

------------------------------
I copy/paste their coldfusion json sample from here and get the following error

JSON parsing failure at character 1:'C' in Connection Failure

It sounds like there's nothing wrong with the parsing code, the problem is w/your connection. ie If the connection fails you're getting back an error instead of valid xml/json content. So there's nothing to parse. From what Tomarse111 described, his connection is fine. That's why it works for him.

Before you attempt any parsing, dump the cfhttp response and check the status code. It's probably failing (It's a good idea to do that anyway as part of the normal error handling)
<cfdump var="#cfhttp#">

FWIW, I don't have a key, but the JSON string from here parses fine w/CF10
http://www.wunderground.com/weather/api/d/docs?d=data/index&MR=1
0
 

Author Comment

by:cb_it
ID: 39194596
Charset [empty string]  
ErrorDetail Connect Exception: Connection to http://api.wunderground.com refused  
Filecontent Connection Failure  
Header [empty string]  
Mimetype Unable to determine MIME type of file.  
Responseheader struct [empty]
 
Statuscode Connection Failure. Status code unavailable.  
Text YES
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39194624
I hadn't seen all the responses before posting, but .. I tried the JSON example here:

http://www.wunderground.com/weather/api/d/docs?d=resources/code-samples

with the key in Tomarse111's pastebin example, and it worked fine. @Tomarse111 can you try it from your end again?

<cfhttp url="http://api.wunderground.com/api/xxxxxxxx/geolookup/conditions/q/IA/Cedar_Rapids.json" method="get">
     <cfhttpparam type="header" name="Accept-Encoding" value="*" />
     <cfhttpparam type="Header" name="TE" value="deflate;q=0">
</cfhttp>
<cfdump  var="#cfhttp#">      
<cfset json = deserializeJSON(cfhttp.filecontent)>
<cfdump  var="#json#">
0
 
LVL 15

Expert Comment

by:Tomarse111
ID: 39194654
Yep, that JSON version works fine for me as well, with both my Key and the key posted a few comments up. That code however is slightly tuned / different from their example.

http://www.wunderground.com/weather/api/d/docs?d=resources/code-samples&MR=1

Maybe this is where the problem is stemming?

Tom
0
 
LVL 15

Expert Comment

by:Tomarse111
ID: 39194656
So just to clarify both the XML and JSON examples posted in this thread, work fine for me.
0
 

Author Comment

by:cb_it
ID: 39194671
I'm just stumped, although I love trouble shooting things like this.

Just seems so odd that I can paste the xml url into my browser and it returns valid data, but creating a basic cfm page and it doesnt work. Why would I get a 'Connection failure'. ??
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39194674
> That code however is slightly tuned / different from their example.

Yeah, I was thinking maybe your extra headers made the difference. But it seems to work even without them... Since it works ok for both of us, I'm still wondering if it's a connection problem on cb_it's end.  @cb_it - What happens if view the JSON url in your browser (instead of cfhttp)?

ie http://api.wunderground.com/api/xxxxxxxx/geolookup/conditions/q/IA/Cedar_Rapids.json
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39194683
Gah ... I keep missing posts.  Doing too many things at once.

@cb_it - Anything interesting in your log files? Because it really sounds like a firewall problem ... Also are *any* cfhttp requests successful?
0
 
LVL 15

Expert Comment

by:Tomarse111
ID: 39194691
What happens when you paste the URL for the XML or JSON from the server that coldfusion is hosted on, i.e. the windows box? Your actual CF server may not be able to connect out to the api.wundergroun.com URL. Try pinging from your server as well.

I'm presuming you are simply copying the URL into you local browser and that CF is running separately to your IDE environment.
0
 

Author Comment

by:cb_it
ID: 39194694
Is there a spot in coldfusion to enter a proxy server??
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39194709
Tomarse111 has it well in hand, so I'm going to leave you guys too it :) I just chimed in to confirm that some else could successfully access the url too, so it might be an environment specific problem.  Later guys!
0
 
LVL 15

Accepted Solution

by:
Tomarse111 earned 500 total points
ID: 39194714
0
 

Author Comment

by:cb_it
ID: 39194783
effing proxy

it works, thanks guys for all the help
0
 

Author Comment

by:cb_it
ID: 39194800
Also had to add these 2 lines when using the json example

<cfhttpparam type="header" name="accept-encoding" value="*">
<cfhttpparam type="header" name="te" value="deflate;q=0?">

Found it on this site
http://australiansearchengine.wordpress.com/2009/09/28/cfhttp-connection-failure/
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39194866
Yeah,  Tomarse111 included those headers in his earlier sample. You may have missed it.

> effing proxy
> it works, thanks guys for all the help

don't you love proxies ... ? BTW, no points for me because I just re-confirmed what Tomarse111 said. He did all the work (setting up an account, examples, etc...). I just enjoy group troubleshooting :)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

757 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

21 Experts available now in Live!

Get 1:1 Help Now