SOAP stands for Simple Object Access Protocol. In a nutshell, it is a way for applications to communicate over HTTP using XML.
What I have done is set up a simple example that, given a zip code, will use SOAP to connect to NOAA to retrieve the current weather. Rather than give a wordy explanation, I’ll just post the code below. For simplicity I’ve made this a version that works from the command line. You can download the code below here: Soapy Weather CLI. I have a web based version here that you can try out: Soapy Weather
<?php# This demonstrates how easy it is to use SOAP.# -------------------------------------------------------------------------------# For more information on SOAP, go to:# http://www.w3schools.com/soap/default.asp# For more information on WSDLs, go to:# http://www.w3schools.com/wsdl/default.asp# -------------------------------------------------------------------------------# John Wallace - September 28, 2011 - http://jwallace.usechoPHP_EOL."Soapy Weather (cli version)".PHP_EOL.PHP_EOL;echo'Enter your ZIP code > ';# get the zip code$str=fread(STDIN,80);$zip_code=trim($str);# check zip code for non-numbersif(!ctype_digit($zip_code)){die("error: non-numbers were used in the zip code".PHP_EOL);}echoPHP_EOL;# create a SOAP client using NOAA's WSDL$client=newSoapClient("http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl");$dxml=newSimpleXMLElement($client->LatLonListZipCode($zip_code));# get the latitude and longitude of the zip code$location=preg_split('/(,)/',$dxml->latLonList);# setting a time zone is required to use the date functiondate_default_timezone_set('America/Chicago');$dateTime=date("c");# get the current weather$dxml=newSimpleXMLElement($client->NDFDgen($location[0],$location[1],'time-series',$dateTime,$dateTime,'e','temp'));echo"Current conditions for $zip_code (".$dxml->data->location->point['latitude'].",".$dxml->data->location->point['longitude'].") are: ".PHP_EOL.PHP_EOL;# now parse and present the weather data returned in an XML formatforeach($dxml->data->parametersas$parameter){foreach($parameteras$element){if(count($element)>1){if($element->value!=""){echo$element->name.": [".$element->value."]".PHP_EOL;}}else{foreach($elementas$sub_element){if($element->value!=""){echo$sub_element->name.": [".$sub_element->value."]".PHP_EOL;}}}}}echoPHP_EOL."Done!".PHP_EOL;?>