--jay
PS, sorry if I'm a bit incoherent. I have a really nasty cold right
now :(
Hi,
Sorry for late reply. I was unconscious this thread. I wrote sample
client of this weather service for another person and find this article
in Google search.
tsuraan wrote:
> Has anyone used soap4r with the US weather service's soap server? I'm
> having trouble figuring out how the array that the service uses should
> map into ruby. I've tried using wsdl2ruby to convert the wsdl
> automatically to a ruby class, but that doesn't even work. Also, if
> this is the wrong place to be asking this (probably...), could someone
> point me in the right direction? Thanks.
Here's a sample client;
http://dev.ctor.org/soap4r/file/trunk/sample/wsdl/noaa/client.rb
The sample requires the latest snapshot tarball of soap4r at
http://dev.ctor.org/download/
I don't know this service well. The sample clients above seem to access
the service correctly, but I don't know the response is right or not.
Would somebody please check this sample and let me know it works
correctly? I cannot understand the response XML. (What is dwml?) This
service seems to be somewhat popular...
Is there a XML Schema of this dwml thing? I might be able to map a
response XML to Ruby object graph using XML Schema support of soap4r,
like I once did for Yahoo's Search Web Services at
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/132666
Regards,
// NaHi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)
iD8DBQFCX8kMf6b33ts2dPkRAq+gAJsE4IxT/F51f08xtpHuaEaExpvp/QCfcKNW
Nhr3SZWWQGvxkdobTtfGntw=
=fJkD
-----END PGP SIGNATURE-----
The problem that I had was when I set various elements to false, the
server would still send me all the data that it could. It's not really
a problem, since ignoring unwanted data isn't painful, but it's
annoying. I'd try the client out, but I'm waiting on a new motherboard
for my dev machine.
> I cannot understand the response XML. (What is dwml?) This
> service seems to be somewhat popular...
>
> Is there a XML Schema of this dwml thing? I might be able to map a
> response XML to Ruby object graph using XML Schema support of soap4r,
> like I once did for Yahoo's Search Web Services at
> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/132666
A somewhat useful description of the XML response can be found at
http://weather.gov/mdl/XML/Design/MDL_XML_Design.pdf . I had something
better, but I'm not sure where it is. A document containing the "NDFD
XML Schema" is
http://products.weather.gov/PDD/Extensible_Markup_Language.pdf (See
appendix B), but I didn't find that to be very useful. Basically, if
you understand the keys it's pretty easy to convert the XML response
into something usable. I had it almost working, but then my
motherboard flaked out and killed everything on my hard drive. Stupid
computers...
--jay
Hi,
tsuraan wrote:
>> Here's a sample client;
>> http://dev.ctor.org/soap4r/file/trunk/sample/wsdl/noaa/client.rb
>> The sample requires the latest snapshot tarball of soap4r at
>> http://dev.ctor.org/download/
>>
>> I don't know this service well. The sample clients above seem to access
>> the service correctly, but I don't know the response is right or not.
>> Would somebody please check this sample and let me know it works
>> correctly?
>
> The problem that I had was when I set various elements to false, the
> server would still send me all the data that it could. It's not really
Hmm. Actually the sample retrieved all data. And when I set false
instead of nil for each param, the server responses narrowed XML
document (http://dev.ctor.org/soap4r/changeset/1485). Same as ever, I
don't know the response is correct or not... Anyway, could it be the
same problem?
> A somewhat useful description of the XML response can be found at
> http://weather.gov/mdl/XML/Design/MDL_XML_Design.pdf . I had something
> better, but I'm not sure where it is. A document containing the "NDFD
> XML Schema" is
> http://products.weather.gov/PDD/Extensible_Markup_Language.pdf (See
> appendix B), but I didn't find that to be very useful. Basically, if
> you understand the keys it's pretty easy to convert the XML response
> into something usable. I had it almost working, but then my motherboard
Thank you. I'll look into this.
> flaked out and killed everything on my hard drive. Stupid computers...
It's really too bad...
Regards,
// NaHi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)
iD8DBQFCYMfLf6b33ts2dPkRAojiAKCCY1cXUJCI933e2XeC5Y9UV/GEHQCdGLMm
ZSIaNHSWkccoQp+V+lybgzg=
=U3ER
-----END PGP SIGNATURE-----
NAKAMURA, Hiroshi wrote:
>>>A somewhat useful description of the XML response can be found at
>>>http://weather.gov/mdl/XML/Design/MDL_XML_Design.pdf . I had something
>>>better, but I'm not sure where it is. A document containing the "NDFD
>>>XML Schema" is
>>>http://products.weather.gov/PDD/Extensible_Markup_Language.pdf (See
>>>appendix B), but I didn't find that to be very useful. Basically, if
>>>you understand the keys it's pretty easy to convert the XML response
>>>into something usable. I had it almost working, but then my motherboard
>
> Thank you. I'll look into this.
Seems to be a simple XML structure as you said. Here is an example.
# To run the following code, you need to get the latest
# soap4r module from SVN repository.
Regards,
// NaHi
## preparing
t = Time.now
starter = Time.local(t.year,t.mon, t.day) + (24 *3600)
ender = starter + 7 * 24 *3600
lattitude = 39.0
longitude = -77.0
## accessing through dynamically generated driver
require 'soap/wsdlDriver'
params = {:maxt => false, :mint => false, :temp => true, :dew => true,
:pop12 => false, :qpf => false, :sky => false, :snow => false,
:wspd => false, :wdir => false, :wx => false, :waveh => false,
:icons => false}
wsdl = "http://weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl"
drv = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
drv.wiredump_dev = STDOUT if $DEBUG
dwml = drv.NDFDgen(lattitude, longitude, 'time-series', starter, ender,
params)
puts dwml
soap = SOAP::Processor.unmarshal(dwml)
data = SOAP::Mapping.soap2obj(soap["data"])
data.parameters.temperature.each do |temp|
p temp.name
p temp.value
end
p data["time-layout"]["start-valid-time"]
# =>
"Temperature"
["35", "31", "39", "57", "67", "68", "58", "51", "48", "45", "51", "65",
"73", "73", "64", "54", "58", "78", "67", "57", "60", "81", "69", "57",
"58", "71", "62", "53", "55", "69", "61"]
"Dew Point Temperature"
["29", "29", "32", "30", "31", "34", "36", "38", "40", "42", "43", "43",
"43", "44", "45", "48", "49", "49", "51", "52", "52", "53", "53", "51",
"50", "49", "48", "46", "45", "44", "45"]
["2005-04-17T02:00:00-04:00", "2005-04-17T05:00:00-04:00",
"2005-04-17T08:00:00-04:00", "2005-04-17T11:00:00-04:00",
"2005-04-17T14:00:00-04:00", "2005-04-17T17:00:00-04:00",
"2005-04-17T20:00:00-04:00", "2005-04-17T23:00:00-04:00",
"2005-04-18T02:00:00-04:00", "2005-04-18T05:00:00-04:00",
"2005-04-18T08:00:00-04:00", "2005-04-18T11:00:00-04:00",
"2005-04-18T14:00:00-04:00", "2005-04-18T17:00:00-04:00",
"2005-04-18T20:00:00-04:00", "2005-04-19T02:00:00-04:00",
"2005-04-19T08:00:00-04:00", "2005-04-19T14:00:00-04:00",
"2005-04-19T20:00:00-04:00", "2005-04-20T02:00:00-04:00",
"2005-04-20T08:00:00-04:00", "2005-04-20T14:00:00-04:00",
"2005-04-20T20:00:00-04:00", "2005-04-21T02:00:00-04:00",
"2005-04-21T08:00:00-04:00", "2005-04-21T14:00:00-04:00",
"2005-04-21T20:00:00-04:00", "2005-04-22T02:00:00-04:00",
"2005-04-22T08:00:00-04:00", "2005-04-22T14:00:00-04:00",
"2005-04-22T20:00:00-04:00"]