Problem with soap4r

I'm trying to write a client that fetches a weather forecast using soap4R.

require 'soap/wsdlDriver'
weather = SOAP::WSDLDriverFactory.new(
   "http://www.nws.noaa.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl"
).create_driver

This works ok and weather is created.

My problem is how do I enter the parameters for the function call
the parameters are:
<part name="latitude" type="xsd:decimal" />
  <part name="longitude" type="xsd:decimal" />
  <part name="product" type="typens:productType" />
  <part name="startTime" type="xsd:dateTime" />
  <part name="endTime" type="xsd:dateTime" />
   <part name="weatherParameters" type="typens:weatherParametersType" />

   The weatherParameters variable is an array of booleans eg. maxt, mint,
others

sReceived=NDFDgen("What goes here"........)

Any help would be appreciated.

Ernie

Ernie wrote:

I'm trying to write a client that fetches a weather forecast using soap4R.

require 'soap/wsdlDriver'
weather = SOAP::WSDLDriverFactory.new(
   "http://www.nws.noaa.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl&quot;
).create_driver

This works ok and weather is created.

My problem is how do I enter the parameters for the function call
the parameters are:
<part name="latitude" type="xsd:decimal" />
  <part name="longitude" type="xsd:decimal" />
  <part name="product" type="typens:productType" />
  <part name="startTime" type="xsd:dateTime" />
  <part name="endTime" type="xsd:dateTime" />
   <part name="weatherParameters" type="typens:weatherParametersType" />

   The weatherParameters variable is an array of booleans eg. maxt, mint,
others

sReceived=NDFDgen("What goes here"........)

Any help would be appreciated.

Ernie

I started making a client for that service in Python. The only tricky part is the array of booleans. If my thinking is correct, a hashmap will work there. So do something like this.

....
lattitude = 15.0
longitude = 15.0
product = "glance"
startTime = "The time format they use, I forget"
endTime = "The same"
weatherParameters = { 'maxt' => true, 'mint' => false, .... }

Response = NDFDgen( lattitude, longitude, product, startTime, endTime, weatherParameters )

If my thinking is correct this will work. If it doesn't, then the hashmap might not be correct. You may have to manually create a SOAP structure for the weather parameters. Let me know how it goes. The real trouble you will have is writing a parser for the response, it is in a very ugly format.

"Scott Rubin" <srubin@fsisys.com> wrote in message
news:40f3e83a@buckaroo.cs.rit.edu...

Ernie wrote:
> I'm trying to write a client that fetches a weather forecast using

soap4R.

>
> require 'soap/wsdlDriver'
> weather = SOAP::WSDLDriverFactory.new(
> "http://www.nws.noaa.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl&quot;
> ).create_driver
>
> This works ok and weather is created.
>
> My problem is how do I enter the parameters for the function call
> the parameters are:
> <part name="latitude" type="xsd:decimal" />
> <part name="longitude" type="xsd:decimal" />
> <part name="product" type="typens:productType" />
> <part name="startTime" type="xsd:dateTime" />
> <part name="endTime" type="xsd:dateTime" />
> <part name="weatherParameters" type="typens:weatherParametersType" />
>
> The weatherParameters variable is an array of booleans eg. maxt,

mint,

> others
>
>
> sReceived=NDFDgen("What goes here"........)
>
> Any help would be appreciated.
>
> Ernie
>
>

I started making a client for that service in Python. The only tricky
part is the array of booleans. If my thinking is correct, a hashmap
will work there. So do something like this.

...
lattitude = 15.0
longitude = 15.0
product = "glance"
startTime = "The time format they use, I forget"
endTime = "The same"
weatherParameters = { 'maxt' => true, 'mint' => false, .... }

Response = NDFDgen( lattitude, longitude, product, startTime, endTime,
weatherParameters )

If my thinking is correct this will work. If it doesn't, then the
hashmap might not be correct. You may have to manually create a SOAP
structure for the weather parameters. Let me know how it goes. The real
  trouble you will have is writing a parser for the response, it is in a
very ugly format.

Thanks for the help. I've tried this method and others but I keep getting
this message
Unknown element {http://www.w3.org/2001/XMLSchema}simpleType.
Don't know where that error is generated. Tried grepping for 'Unknown' and
'Unknown element' but can't find any files where the phrase 'Unknown
element appears.

After this message I get this
c:/ruby/lib/ruby/site_ruby/1.8/soap/mapping/wsdlRegistry.rb:73:in
`obj2soap': Cannot map String to SOAP/OM. (SOAP::Mapping::MappingError)
I'm sure this error is directly related to the Unknown element message
because this error is occuring when it obj2soap is processing 'product'
which is defined by NOAA's wsdl as xsd:simpleType.
I have no clue what is wrong here. the w2.rog/2001/XMLSchema defines
simpleType. Does soap4r have a problem or does the NOAA wsdl have a
problem?

Ernie

Hi,

Ernie wrote:

require 'soap/wsdlDriver'
weather = SOAP::WSDLDriverFactory.new(
  "http://www.nws.noaa.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl&quot;
).create_driver

This works ok and weather is created.

My problem is how do I enter the parameters for the function call
the parameters are:
<part name="latitude" type="xsd:decimal" />
<part name="longitude" type="xsd:decimal" />
<part name="product" type="typens:productType" />
<part name="startTime" type="xsd:dateTime" />
<part name="endTime" type="xsd:dateTime" />
  <part name="weatherParameters" type="typens:weatherParametersType" />

  The weatherParameters variable is an array of booleans eg. maxt,

Try wsdl2ruby.rb which is included in soap4r/1.5.2.

0% wsdl2ruby.rb --wsdl ndfdXML.wsdl --classdef --force
I, [2004-07-14T21:02:19.761942 #224] INFO -- app: Creating class definition.
I, [2004-07-14T21:02:19.762942 #224] INFO -- app: Creates file 'default.rb'.
I, [2004-07-14T21:02:19.767942 #224] INFO -- app: End of app. (status: 0)
0% cat default.rb
# http://www.nws.noaa.gov/forecasts/xml/DWMLgen/schema/ndfdXML.xsd
class WeatherParametersType
   @@schema_type = "weatherParametersType"
   @@schema_ns = "http://www.nws.noaa.gov/forecasts/xml/DWMLgen/schema/ndfdXML.xsd&quot;

   attr_accessor :maxt
   [snip]
   attr_accessor :icons

   def initialize(maxt = nil, mint = nil, temp = nil, dew = nil, pop12 = nil, qpf = nil, sky = nil, snow = nil, wspd = nil, wdir = nil, wx = nil, waveh = nil, icons = nil)
     @maxt = maxt
     [snip]
     @icons = icons
   end
end

# http://www.nws.noaa.gov/forecasts/xml/DWMLgen/schema/ndfdXML.xsd
module ProductType
   Glance = "glance"
   TimeSeries = "time-series"
end
0%

"moduel ProductType" might not be dumped under soap4r/1.5.2. Once you install ruby's current CVS (or snapshot for 1.8.2), it will be dumped. So, it should work.

0% ruby -rsoap/wsdlDriver -rdefault -e '
now = Time.now
drv = SOAP::WSDLDriverFactory.new("http://www.nws.noaa.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl&quot;\).create_driver
drv.NDFDgen(123, 456, ProductType::Glance, now - 60, now, WeatherParametersType.new)
'

...though I don't know what is the meaning of each parameter.

Just ignore "simpleType" warning untill 1.8.2 to be released. Sorry for the inconvenience.

Regards,
// NaHi

Thanks, I'll give this a try. I'm running Windows XP and ruby 1.81. So
I'll double check on the module.
By the way, I have been getting this information via a simple form post to a
web server runing a php script that ships the
xml out in the same form. I don't know how long that service will run, so I
thought I'd give SOAP a try. If NOAA continues the
web service, it will probably be only SOAP.

Thanks again.

Ernie
"NAKAMURA, Hiroshi" <nahi@keynauts.com> wrote in message
news:40F522C7.1010607@keynauts.com...

Hi,

Ernie wrote:
>>>require 'soap/wsdlDriver'
>>>weather = SOAP::WSDLDriverFactory.new(
>>> "http://www.nws.noaa.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl&quot;
>>>).create_driver
>>>
>>>This works ok and weather is created.
>>>
>>>My problem is how do I enter the parameters for the function call
>>>the parameters are:
>>><part name="latitude" type="xsd:decimal" />
>>> <part name="longitude" type="xsd:decimal" />
>>> <part name="product" type="typens:productType" />
>>> <part name="startTime" type="xsd:dateTime" />
>>> <part name="endTime" type="xsd:dateTime" />
>>> <part name="weatherParameters" type="typens:weatherParametersType"

/>

>>>
>>> The weatherParameters variable is an array of booleans eg. maxt,

Try wsdl2ruby.rb which is included in soap4r/1.5.2.

0% wsdl2ruby.rb --wsdl ndfdXML.wsdl --classdef --force
I, [2004-07-14T21:02:19.761942 #224] INFO -- app: Creating class
definition.
I, [2004-07-14T21:02:19.762942 #224] INFO -- app: Creates file
'default.rb'.
I, [2004-07-14T21:02:19.767942 #224] INFO -- app: End of app. (status: 0)
0% cat default.rb
# http://www.nws.noaa.gov/forecasts/xml/DWMLgen/schema/ndfdXML.xsd
class WeatherParametersType
   @@schema_type = "weatherParametersType"
   @@schema_ns =
"http://www.nws.noaa.gov/forecasts/xml/DWMLgen/schema/ndfdXML.xsd&quot;

   attr_accessor :maxt
   [snip]
   attr_accessor :icons

   def initialize(maxt = nil, mint = nil, temp = nil, dew = nil, pop12 =
nil, qpf = nil, sky = nil, snow = nil, wspd = nil, wdir = nil, wx = nil,
waveh = nil, icons = nil)
     @maxt = maxt
     [snip]
     @icons = icons
   end
end

# http://www.nws.noaa.gov/forecasts/xml/DWMLgen/schema/ndfdXML.xsd
module ProductType
   Glance = "glance"
   TimeSeries = "time-series"
end
0%

"moduel ProductType" might not be dumped under soap4r/1.5.2. Once you
install ruby's current CVS (or snapshot for 1.8.2), it will be dumped.
So, it should work.

0% ruby -rsoap/wsdlDriver -rdefault -e '
now = Time.now
drv =

SOAP::WSDLDriverFactory.new("http://www.nws.noaa.gov/forecasts/xml/DWMLgen/w
sdl/ndfdXML.wsdl").create_driver

···

drv.NDFDgen(123, 456, ProductType::Glance, now - 60, now,
WeatherParametersType.new)
'

..though I don't know what is the meaning of each parameter.

Just ignore "simpleType" warning untill 1.8.2 to be released. Sorry for
the inconvenience.

Regards,
// NaHi