Jump to content
Sign in to follow this  
thekirbster

Soapclient And The Ndfd Weather Database

Recommended Posts

So I've been trying to put together a little weather application using the NOAA's weather feed. The site I am connecting to is http://graphical.weather.gov/xml/ Basically, I'm a newbie when it comes to PHP. I want to code it such that a user can enter a zip code and retrieve a host of climatic data. If any one is familiar with tapping into this database (the NDFD) and could help, I'd be very grateful. Below is the code. I first want to retrieve the latitude and longitude of a given zip code and then, because both coordinates are given as a string, I want to break them up into $Lat and $Lon, respectively, and I've been successful with these specific steps. However, I believe I am running into trouble generating the XML from the $result variable and running into trouble with the subsequent parsing on the XML. I'm thinking the issue is with how I am calling the NuSoap client and associated NDFD server file. Anyways, here's the code, and I'd be very appreciative of any help. Thanks.

 <?php /* http://sourceforge.net/projects/nusoap/ */require('../lib/nusoap.php'); $getZip = array('zipCodeList' => $_GET['zipCodeList']); try{ $c = new nusoap_client('http://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl', 'wsdl'); $LatLonList = $c->call('LatLonListZipCode',$getZip);  $LatLonStr = $LatLonList; $LatLon = explode(',', $LatLonStr, 2);$Lat = ($LatLon[0]);$Lon = ($LatLon[1]); $parameters = array('product' => 'glance','numDays'   => 5,'format'    => '24 hourly','latitude' => $Lat,                    'longitude'  => $Lon);  $result = $c->call('NDFDgen', $parameters);}catch (Excepion $ex){/* nuSOAP throws an exception is there was a problem fetching the data */echo 'failed';}   /* parse the XML data into a giant data object */try{$xml = new SimpleXMLElement($result);}catch (Exception $ex){/* the XML was probably invalid */die('Failed to parse the XML');}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...