# Problem with soap4r

**URL:** <https://rubytalk.org/t/problem-with-soap4r/12544>\
**Category:** ruby-talk\
**Created:** [13 July 2004 13:12 UTC](https://rubytalk.org/t/problem-with-soap4r/12544 "2004-07-13T13:12:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ernest\_Ellingson1](https://avatars.discourse-cdn.com/v4/letter/e/90db22/32.png) [@Ernest\_Ellingson1](https://rubytalk.org/u/Ernest_Ellingson1)\
**Post date:** [13 July 2004 13:12 UTC](https://rubytalk.org/t/problem-with-soap4r/12544/1 "2004-07-13T13:12:22Z")

</div>

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

require 'soap/wsdlDriver'  
weather = SOAP::WSDLDriverFactory.new(  
&nbsp;&nbsp;&nbsp;"[http://www.nws.noaa.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl](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" /\>  
&nbsp;&nbsp;\<part name="longitude" type="xsd:decimal" /\>  
&nbsp;&nbsp;\<part name="product" type="typens:productType" /\>  
&nbsp;&nbsp;\<part name="startTime" type="xsd:dateTime" /\>  
&nbsp;&nbsp;\<part name="endTime" type="xsd:dateTime" /\>  
&nbsp;&nbsp;&nbsp;\<part name="weatherParameters" type="typens:weatherParametersType" /\>

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

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

Any help would be appreciated.

Ernie

---

<div class="post-metadata">

**Author:** ![Scott\_Rubin1](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@Scott\_Rubin1](https://rubytalk.org/u/Scott_Rubin1)\
**Post date:** [13 July 2004 13:57 UTC](https://rubytalk.org/t/problem-with-soap4r/12544/2 "2004-07-13T13:57:23Z")

</div>

Ernie wrote:

> I'm trying to write a client that fetches a weather forecast using soap4R.
> 
> require 'soap/wsdlDriver'  
> weather = SOAP::WSDLDriverFactory.new(  
> &nbsp;&nbsp;&nbsp;"[http://www.nws.noaa.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl&quot](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" /\>  
> &nbsp;&nbsp;\<part name="longitude" type="xsd:decimal" /\>  
> &nbsp;&nbsp;\<part name="product" type="typens:productType" /\>  
> &nbsp;&nbsp;\<part name="startTime" type="xsd:dateTime" /\>  
> &nbsp;&nbsp;\<part name="endTime" type="xsd:dateTime" /\>  
> &nbsp;&nbsp;&nbsp;\<part name="weatherParameters" type="typens:weatherParametersType" /\>
> 
> &nbsp;&nbsp;&nbsp;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.

---

<div class="post-metadata">

**Author:** ![Ernest\_Ellingson1](https://avatars.discourse-cdn.com/v4/letter/e/90db22/32.png) [@Ernest\_Ellingson1](https://rubytalk.org/u/Ernest_Ellingson1)\
**Post date:** [13 July 2004 14:27 UTC](https://rubytalk.org/t/problem-with-soap4r/12544/3 "2004-07-13T14:27:29Z")

</div>

"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](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  
> &nbsp;&nbsp;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](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

---

<div class="post-metadata">

**Author:** ![NAKAMURA\_Hiroshi1](https://avatars.discourse-cdn.com/v4/letter/n/fbc32d/32.png) [@NAKAMURA\_Hiroshi1](https://rubytalk.org/u/NAKAMURA_Hiroshi1)\
**Post date:** [14 July 2004 12:11 UTC](https://rubytalk.org/t/problem-with-soap4r/12544/4 "2004-07-14T12:11:29Z")

</div>

Hi,

Ernie wrote:

> > > require 'soap/wsdlDriver'  
> > > weather = SOAP::WSDLDriverFactory.new(  
> > > &nbsp;&nbsp;"[http://www.nws.noaa.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl&quot](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" /\>  
> > > &nbsp;&nbsp;\<part name="weatherParameters" type="typens:weatherParametersType" /\>
> > > 
> > > &nbsp;&nbsp;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](http://www.nws.noaa.gov/forecasts/xml/DWMLgen/schema/ndfdXML.xsd)  
class WeatherParametersType  
&nbsp;&nbsp;&nbsp;@@schema\_type = "weatherParametersType"  
&nbsp;&nbsp;&nbsp;@@schema\_ns = "[http://www.nws.noaa.gov/forecasts/xml/DWMLgen/schema/ndfdXML.xsd&quot](http://www.nws.noaa.gov/forecasts/xml/DWMLgen/schema/ndfdXML.xsd&quot);

&nbsp;&nbsp;&nbsp;attr\_accessor :maxt  
&nbsp;&nbsp;&nbsp;[snip]  
&nbsp;&nbsp;&nbsp;attr\_accessor :icons

&nbsp;&nbsp;&nbsp;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)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@maxt = maxt  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[snip]  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@icons = icons  
&nbsp;&nbsp;&nbsp;end  
end

# [http://www.nws.noaa.gov/forecasts/xml/DWMLgen/schema/ndfdXML.xsd](http://www.nws.noaa.gov/forecasts/xml/DWMLgen/schema/ndfdXML.xsd)  
module ProductType  
&nbsp;&nbsp;&nbsp;Glance = "glance"  
&nbsp;&nbsp;&nbsp;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;\](http://www.nws.noaa.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl&quot;%5C)).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

---

<div class="post-metadata">

**Author:** ![Ernest\_Ellingson1](https://avatars.discourse-cdn.com/v4/letter/e/90db22/32.png) [@Ernest\_Ellingson1](https://rubytalk.org/u/Ernest_Ellingson1)\
**Post date:** [14 July 2004 19:47 UTC](https://rubytalk.org/t/problem-with-soap4r/12544/5 "2004-07-14T19:47:20Z")

</div>

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](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](http://www.nws.noaa.gov/forecasts/xml/DWMLgen/schema/ndfdXML.xsd)  
> class WeatherParametersType  
> &nbsp;&nbsp;&nbsp;@@schema\_type = "weatherParametersType"  
> &nbsp;&nbsp;&nbsp;@@schema\_ns =  
> "[http://www.nws.noaa.gov/forecasts/xml/DWMLgen/schema/ndfdXML.xsd&quot](http://www.nws.noaa.gov/forecasts/xml/DWMLgen/schema/ndfdXML.xsd&quot);
> 
> &nbsp;&nbsp;&nbsp;attr\_accessor :maxt  
> &nbsp;&nbsp;&nbsp;[snip]  
> &nbsp;&nbsp;&nbsp;attr\_accessor :icons
> 
> &nbsp;&nbsp;&nbsp;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)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@maxt = maxt  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[snip]  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@icons = icons  
> &nbsp;&nbsp;&nbsp;end  
> end
> 
> # [http://www.nws.noaa.gov/forecasts/xml/DWMLgen/schema/ndfdXML.xsd](http://www.nws.noaa.gov/forecasts/xml/DWMLgen/schema/ndfdXML.xsd)  
> module ProductType  
> &nbsp;&nbsp;&nbsp;Glance = "glance"  
> &nbsp;&nbsp;&nbsp;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](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
