Utilizing NOAA Weather XML via Web Services

Album Cover: The Black Album

"Young enough to know the right car to buy yet grown enough not to put rims on it."
Jay-Z / 30 Something

Posted on December 17, 2004 4:19 PM in XML
Warning: This blog entry was written two or more years ago. Therefore, it may contain broken links, out-dated or misleading content, or information that is just plain wrong. Please read on with caution.

A couple weeks ago, Wired News announced that the National Weather Service was going to open up access to its National Digital Forecast Database via web services. This means that, theoretically, anyone and their dog can access and manipulate raw weather data "for free" simply by communicating via SOAP and processing XML.

After the new service was announced (and subsequently covered on Slashdot), hackers got busy right away. There are already examples of utilizing the service via Perl and PHP available online. Up to this point, however, I haven't seen any examples of how to connect to the service using C#, so I decided to post my own code for anyone who might be interested.

using WeatherApp.gov.noaa.nws.www;


// default to Seattle (just 'cause)
decimal lon = -122.33;
decimal lat = 47.60;

// create the NOAA Weather XML object
ndfdXML wx = new ndfdXML();

// create the date span and data types
DateTime st = DateTime.Now;
DateTime et = st.AddDays(1);
weatherParametersType wparams =
  new weatherParametersType();
wparams.maxt = true;
wparams.mint = true;
wparams.temp = false;
wparams.dew = false;
wparams.pop12 = true;
wparams.qpf = false;
wparams.snow = false;
wparams.sky = false;
wparams.wspd = false;
wparams.wdir = false;
wparams.wx = true;
wparams.icons = false;
wparams.waveh = false;

// request weather data
string xml =
  wx.NDFDgen(lat, lon, productType.glance, st, et, wparams);


It's pretty easy to see that this example is very basic. I've copied the code directly from a program I'm writing that is more complex, but I snipped and modified certain sections for readability and learnability's sake. There's obviously more code that needs to be written to parse/transform the string xml that gets returned, and typically you'll want to support more than just one city ;)

Another downside to what I've written here is that I can't seem to get it to connect. Whenever my program hits the line where the NDFDgen function is called, it freezes up only to time out about a minute later. I'm fairly confident I've coded the request according to the National Weather Service's description, so my only other guess is that something is wrong with the way they are handling incoming SOAP requests from .NET. Afterall, despite what some may think, the service is still in an experimental state and seems to be a little rough around the edges.

If I'm doing something blatantly wrong, though, I'd love to hear about it. Who knows, maybe even someone from the National Weather Service will drop by – it has happened before!


S h i S h on December 20, 2004 at 5:35 PM:

umm .. I have written an Excel Application using VSTO against the NOAA webservice and seem to get the exact same error as you. I initially tried creating an InfoPath form to consume this WS but found out that it is RPC encoded and not Document literal. Would love to know when you have a breakthrough with this. cheers


Alexey on February 03, 2005 at 5:21 PM:

i havent figured out how to send the request via SOAP but i did write a POST request that sends me xml response back. was wondering if you could share some info on how to write SOAP request in C#, would apretiate it.


Andrew on October 03, 2009 at 1:23 PM:
Nasir on July 29, 2014 at 10:28 PM:

Sir i cant add the library
using WeatherApp.gov.noaa.nws.www;

It gives me error of not found so please can you guid me what should i do to resolve this problem ?


Manual Niche Relevant backlinks on October 03, 2016 at 11:33 PM:

i am for the first time here. I found this board and I in finding It truly helpful & it helped me out a lot. I hope to present something back and help others such as you helped me.


Piano For All Download on October 09, 2016 at 10:34 PM:

I have read your article, it is very informative and helpful for me.I admire the valuable information you offer in your articles. Thanks for posting it..


adeus estrias on January 24, 2017 at 12:01 AM:

Admiring the time and effort you put into your blog and detailed information you offer!..


voyance-amour-eternel.com on January 31, 2017 at 11:46 PM:

Hello, I have browsed most of your posts. This post is probably where I got the most useful information for my research. Thanks for posting, maybe we can see more on this. Are you aware of any other websites on this subject.


the best undershirts on February 01, 2017 at 11:39 PM:

Superbly written article, if only all bloggers offered the same content as you, the internet would be a far better place..


Atlam Mikey on February 05, 2017 at 9:56 PM:

I like this post,And I figure that they having a great time to peruse this post,they might take a decent site to make an information,thanks for sharing it to me.
Citation Flow


James Cangelosie on February 19, 2017 at 10:16 PM:

You know your projects stand out of the herd. There is something special about them. It seems to me all of them are really brilliant! High Trust Flow Backlinks


Post Comments

If you feel like commenting on the above item, use the form below. Your email address will be used for personal contact reasons only, and will not be shown on this website.


Email Address:



Check this box if you hate spam.