Copy link to clipboard
Copied
There are 3 methods to use with cdyne: (1) getcityweatherbyzip (2) getcityforecastbyzip (3) getWeatherInformation
More information can be found on their site at http://ws.cdyne.com/WeatherWS/Weather.asmx
The first two are pretty straightforward and return the values needed:
<cfinvoke webservice="http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl" method="getcityweatherbyzip" returnvariable="aWeatherReturn">
<cfinvokeargument name="ZIP" value="27502"/>
</cfinvoke>
<cfoutput>
#aweatherreturn.weatherid#<Br />
#aWeatherReturn.temperature#<br />
#aweatherreturn.description#<Br />
#aweatherreturn.weatherstationcity#<br />
</cfoutput>
<cfdump var="#aweatherreturn#">
I am stumped on method 3, getWeatherInformation. Does anyone know how to get the returned values for weatherid, description, and pictureURL from this method? I don't get this. How does it know what area/zip for this method?
<cfinvoke webservice="http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl" method="getweatherinformation" returnvariable="bWeatherReturn">
</cfinvoke>
<cfdump var="#bweatherReturn#">
<cfoutput>#bweatherreturn.weatherdescription#<Br />
</cfoutput>
Here is an example of my results for both methods:
http://shepherdsvineyardpool.com/sites/dsp/dsp_weather.cfm
Thank YOU! Once this is resolved, I hope to have CDYNE post this example on their website to help others. They have an example of the other methods, but not this one.
Copy link to clipboard
Copied
I am stumped on method 3, getWeatherInformation. Does
anyone know how to get the returned values for weatherid,
description, and pictureURL from this method? I don't get
this. How does it know what area/zip for this method?
I do not think it is doing what you are thinking.. It seems to return a list of standard weather codes (Partly Sunny, Clear, etcetera) and the images used for each.
<cfinvoke webservice="http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl" method="getweatherinformation" returnvariable="bWeatherReturn" />
<cfset weatherArray = bweatherReturn.getWeatherDescription()>
<cfloop array="#weatherArray#" index="weather">
<cfoutput>
#weather.weatherid#<Br />
#weather.Description#<br />
#weather.PictureURL#<Br />
</cfoutput>
</cfloop>
Message was edited by: -==cfSearching==-
Copy link to clipboard
Copied
Thank you! It was wishful thinking on my part that it would combine the zip code with the description. I put a simple <cfif> in the weather description loop that you created to get the results I wanted. I was so locked into making it do what I wanted that I couldn't even get the array right! Thank you so much. The array is just what I needed to make this work. Thank you for your time.
![]()
<cfinvoke webservice="http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl" method="getcityweatherbyzip" returnvariable="aWeatherReturn">
<cfinvokeargument name="ZIP" value="27502"/>
</cfinvoke>
<cfinvoke webservice="http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl" method="getweatherinformation" returnvariable="bWeatherReturn">
</cfinvoke>
<cfset weatherArray = bweatherReturn.getWeatherDescription()>
<cfloop array="#weatherArray#" index="weather">
<cfif weather.weatherid eq aweatherreturn.weatherid>
<cfoutput>
<img src="#weather.PictureURL#" /><Br />#aWeatherReturn.temperature#
</cfoutput>
</cfif>
</cfloop>
Copy link to clipboard
Copied
You are welcome.
By the way, if you only need one specific image there should be a getWeatherDescription(weatherID) method too. You could use that method instead of having to loop through all of the descriptions every time.
Copy link to clipboard
Copied
What you're suggesting here is what I was initially trying to accomplish. I have no idea how to call the record for a particular weatherid. I output the record number and weatherid which don't match up.
aweatherreturn.weatherid = 14
bweatherreturn.weatherid = 14
bweatherreturn record # = 17
When I do it like this, <cfoutput>#weatherarray[aweatherreturn.weatherid].weatherid#</cfoutput>, so it is like:
weatherarray[14].weatherid = 17 rather than 14. Does that make sense?
http://shepherdsvineyardpool.com/sites/dsp/dsp_weather.cfm?zipcode=27502
Copy link to clipboard
Copied
weatherarray[14].weatherid = 17 rather than 14
I don't fully understand what you are asking. You are looking at the index of 14 of the array which is WeatherID 17 in the list of Weather IDs and descriptions. If you are trying to find a specific weather ID, you should loop through the array to where the weatherarray.weatherid = the ID you are looking for.
Copy link to clipboard
Copied
Yes, I did loop through the array to find the answer. I was referring to another reply that suggested:
"if you only need one specific image there should be a getWeatherDescription(weatherID) method too."
I wasn't sure how to do that method so that I don't have to loop through the entire array. The loop does work, though.
Copy link to clipboard
Copied
On closer examination, that will not work. Initially I thought the getWeatherDescription(int) argument was a "weatherID" value. But it is actually an array index, which will not help here. So you could either loop, or use the other suggestion ie grab the descriptions once and save them rather than retrieving them each time.
Copy link to clipboard
Copied
Ok. That clarifies a lot for me. I initially thought there was a way to do just as you suggested. I couldn't get it to work right
for reasons I now understand.
The looping works fine and doesn't take any time at all. I didn't want to download them to my server in case they change the values on their end.
Thank you for helping me through this learning experience.
Copy link to clipboard
Copied
I didn't want to download them to my server in case they change the values on their end.
True. But you could still design something that updates itself as needed. For example could create an empty structure to store the codes. You could either populate it when the application starts or when the first code is needed (lazy loading). Anyway, each time a code is needed, check the structure to see if the weatherID exists. If it does not, go out to the site and get the current codes and add any missing values to your structure. That would avoid running a request everytime and would still keep things up to date. Granted running a new request and looping is the probably the easiest and most straight forward method 😉
Copy link to clipboard
Copied
The third method does link to the other two with the Weather ID. The third method just simply returns a list of all available weather IDs, their description, and the Picture URL. Once you receive the weather ID from one of the other two methods you can match them up to know the description and have the picture URL.
You could always save the values to your server if you didnt want to loop through them everytime.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now