Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Error calling a SOAP service from within a Rails controller

Reply
Thread Tools

Error calling a SOAP service from within a Rails controller

 
 
Dean Holdren
Guest
Posts: n/a
 
      01-26-2006
The following works fine as a standalone ruby program:
************************************************** *************************=
*******************
t =3D Time.now
starter =3D Time.local(t.year,t.mon, t.day) + (24 *3600)
ender =3D starter + 7 * 24 *3600
lat =3D 40.352039
lon =3D -74.191961

require 'soap/wsdlDriver'

params =3D {:maxt =3D> false, :mint =3D> false, :temp =3D> true, :dew =3D> =
false,
op12 =3D> false, :qpf =3D> false, :sky =3D> false, :snow =3D> false,
:wspd =3D> false, :wdir =3D> false, :wx =3D> false, :waveh =3D> false,
:icons =3D> false, :rh =3D> false, :appt =3D> true}

wsdl =3D "http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl"
drv =3D SOAP::WSDLDriverFactory.new(wsdl).create_rpc_drive r
drv.wiredump_dev =3D STDOUT if $DEBUG
dwml =3D drv.NDFDgen(lat, lon, 'time-series', starter, ender, params)
puts dwml
require 'xsd/mapping'
data =3D XSD::Mapping.xml2obj(dwml).data
************************************************** *************************=
*******************
However, when I try to call the same from within a ruby controller, I get:

SOAP::HTTPStreamError (502: Bad Gateway):
c:/ruby-1.8.4/lib/ruby/1.8/soap/streamHandler.rb:200:in `send_post'
c:/ruby-1.8.4/lib/ruby/1.8/soap/streamHandler.rb:109:in `send'
c:/ruby-1.8.4/lib/ruby/1.8/soap/rpc/proxy.rb:170:in `route'
c:/ruby-1.8.4/lib/ruby/1.8/soap/rpc/proxy.rb:141:in `call'
c:/ruby-1.8.4/lib/ruby/1.8/soap/rpc/driver.rb:178:in `call'
c:/ruby-1.8.4/lib/ruby/1.8/soap/rpc/driver.rb:232:in `nDFDgen'
c:/ruby-1.8.4/lib/ruby/1.8/soap/wsdlDriver.rb:117:in `NDFDgen'

The code in my controller is:
************************************************** *************************=
*******************
def get_weather
lat =3D params[:lat]
lon =3D params[:lon]

t =3D Time.now
starter =3D Time.local(t.year,t.mon, t.day) + (24 *3600)
ender =3D starter + 7 * 24 *3600

params =3D {:maxt =3D> false, :mint =3D> false, :temp =3D>
true, :dew =3D> false,
op12 =3D> false, :qpf =3D> false, :sky =3D> false=
,
:snow =3D> false,
:wspd =3D> false, :wdir =3D> false, :wx =3D> false,
:waveh =3D> false,
:icons =3D> false, :rh =3D> false, :appt =3D> true}

wsdl =3D
"http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl"
drv =3D SOAP::WSDLDriverFactory.new(wsdl).create_rpc_drive r
drv.wiredump_dev =3D STDOUT if $DEBUG
dwml =3D drv.NDFDgen(lat, lon, 'time-series', starter,
ender, params)

@data =3D XSD::Mapping.xml2obj(dwml).data

end
************************************************** *************************=
*******************


 
Reply With Quote
 
 
 
 
Anthony Elizondo
Guest
Posts: n/a
 
      01-26-2006
When you're playing with SOAP in Rails, I think you want to use
ActionWebService. See:
http://rails.rubyonrails.com/classes...ient/Soap.html

For Rails specific questions such as this, try the Rails mailing list,
at http://lists.rubyonrails.org/mailman/listinfo/rails or
http://www.ruby-forum.com/forum/3


 
Reply With Quote
 
 
 
 
Dean Holdren
Guest
Posts: n/a
 
      01-26-2006
thanks, I've tried using ActionWebService::Client::SOAP, but I get the
same error (pretty much), here's the version of the method within my
Controller that used ActionWebService:

def get_weather
lat =3D params[:lat]
lon =3D params[:lon]
=09=09t =3D Time.now
=09=09starter =3D Time.local(t.year,t.mon, t.day) + (24 *3600)
=09=09ender =3D starter + 7 * 24 *3600
=09
=09=09params =3D WeatherParametersType.new({:maxt =3D> false, :mint =3D> fa=
lse,
:temp =3D> true, :dew =3D> false,
=09 =09=09op12 =3D> false, :qpf =3D> false, :sky =3D> false, :snow =3D> =
false,
=09 =09=09:wspd =3D> false, :wdir =3D> false, :wx =3D> false, :waveh =3D> =
false,
=09 =09=09:icons =3D> false, :rh =3D> false, :appt =3D> true})
=09 =09=09
=09 =09soap_client =3D ActionWebService::Client::Soap.new(WeatherAPI,
"http://www.weather.gov/forecasts/xml/SOAP_server/ndfdXMLserver.php")
=09 =09@dwml =3D soap_client.NDFDgen(lat, lon, 'time-series', starter, end=
er, params)
=09 =09@data =3D @dwml
end

and I'm using these classes I've defined:

class WeatherParametersType < ActionWebService::Struct
member :maxt, :boolean
member :mint, :boolean
member :temp, :boolean
member :dew, :boolean
member op12, :boolean
member :qpf, :boolean
member :sky, :boolean
member :snow, :boolean
member :wspd, :boolean
member :wdir, :boolean
member :wx, :boolean
member :waveh, :boolean
member :icons, :boolean
member :rh, :boolean
member :appt, :boolean
end

=09
class WeatherAPI < ActionWebService::API::Base
=09api_method :NDFDgen, :expects =3D> [[Float], [Float], [String], [Time],
[Time], [WeatherParametersType]], :returns =3D> [String]
end

The error stack trace:

SOAP::HTTPStreamError (502: Bad Gateway):
c:/ruby-1.8.4/lib/ruby/1.8/soap/streamHandler.rb:200:in `send_post'
c:/ruby-1.8.4/lib/ruby/1.8/soap/streamHandler.rb:109:in `send'
c:/ruby-1.8.4/lib/ruby/1.8/soap/rpc/proxy.rb:170:in `route'
c:/ruby-1.8.4/lib/ruby/1.8/soap/rpc/proxy.rb:141:in `call'
c:/ruby-1.8.4/lib/ruby/1.8/soap/rpc/driver.rb:178:in `call'
c:/ruby-1.8.4/lib/ruby/1.8/soap/rpc/driver.rb:232:in `NDFDgen'
c:/ruby-1.8.4/lib/ruby/gems/1.8/gems/actionwebservice-1.0.0/lib/action_=
web_s
ervice/client/soap_client.rb:61:in `perform_invocation'
c:/ruby-1.8.4/lib/ruby/gems/1.8/gems/actionwebservice-1.0.0/lib/action_=
web_s
ervice/client/base.rb:15:in `method_missing'

On 1/26/06, Anthony Elizondo <(E-Mail Removed)> wrote:
> When you're playing with SOAP in Rails, I think you want to use
> ActionWebService. See:
> http://rails.rubyonrails.com/classes...ient/Soap.html
>
> For Rails specific questions such as this, try the Rails mailing list,
> at http://lists.rubyonrails.org/mailman/listinfo/rails or
> http://www.ruby-forum.com/forum/3
>



 
Reply With Quote
 
Dean Holdren
Guest
Posts: n/a
 
      01-28-2006
well it turns out I was passing bad parameters to the service. weird
response though...

On 1/26/06, Dean Holdren <(E-Mail Removed)> wrote:
> thanks, I've tried using ActionWebService::Client::SOAP, but I get the
> same error (pretty much), here's the version of the method within my
> Controller that used ActionWebService:
>
> def get_weather
> lat =3D params[:lat]
> lon =3D params[:lon]
> t =3D Time.now
> starter =3D Time.local(t.year,t.mon, t.day) + (24 *3600)
> ender =3D starter + 7 * 24 *3600
>
> params =3D WeatherParametersType.new({:maxt =3D> false, :=

mint =3D> false,
> :temp =3D> true, :dew =3D> false,
> op12 =3D> false, :qpf =3D> false, :sky =3D> fal=

se, :snow =3D> false,
> :wspd =3D> false, :wdir =3D> false, :wx =3D> fals=

e, :waveh =3D> false,
> :icons =3D> false, :rh =3D> false, :appt =3D> tru=

e})
>
> soap_client =3D ActionWebService::Client::Soap.new(Weathe=

rAPI,
> "http://www.weather.gov/forecasts/xml/SOAP_server/ndfdXMLserver.php")
> @dwml =3D soap_client.NDFDgen(lat, lon, 'time-series', st=

arter, ender, params)
> @data =3D @dwml
> end
>
> and I'm using these classes I've defined:
>
> class WeatherParametersType < ActionWebService::Struct
> member :maxt, :boolean
> member :mint, :boolean
> member :temp, :boolean
> member :dew, :boolean
> member op12, :boolean
> member :qpf, :boolean
> member :sky, :boolean
> member :snow, :boolean
> member :wspd, :boolean
> member :wdir, :boolean
> member :wx, :boolean
> member :waveh, :boolean
> member :icons, :boolean
> member :rh, :boolean
> member :appt, :boolean
> end
>
>
> class WeatherAPI < ActionWebService::API::Base
> api_method :NDFDgen, :expects =3D> [[Float], [Float], [String], [=

Time],
> [Time], [WeatherParametersType]], :returns =3D> [String]
> end
>
> The error stack trace:
>
> SOAP::HTTPStreamError (502: Bad Gateway):
> c:/ruby-1.8.4/lib/ruby/1.8/soap/streamHandler.rb:200:in `send_post'
> c:/ruby-1.8.4/lib/ruby/1.8/soap/streamHandler.rb:109:in `send'
> c:/ruby-1.8.4/lib/ruby/1.8/soap/rpc/proxy.rb:170:in `route'
> c:/ruby-1.8.4/lib/ruby/1.8/soap/rpc/proxy.rb:141:in `call'
> c:/ruby-1.8.4/lib/ruby/1.8/soap/rpc/driver.rb:178:in `call'
> c:/ruby-1.8.4/lib/ruby/1.8/soap/rpc/driver.rb:232:in `NDFDgen'
> c:/ruby-1.8.4/lib/ruby/gems/1.8/gems/actionwebservice-1.0.0/lib/actio=

n_web_s
> ervice/client/soap_client.rb:61:in `perform_invocation'
> c:/ruby-1.8.4/lib/ruby/gems/1.8/gems/actionwebservice-1.0.0/lib/actio=

n_web_s
> ervice/client/base.rb:15:in `method_missing'
>
> On 1/26/06, Anthony Elizondo <(E-Mail Removed)> wrote:
> > When you're playing with SOAP in Rails, I think you want to use
> > ActionWebService. See:
> > http://rails.rubyonrails.com/classes...ient/Soap.html
> >
> > For Rails specific questions such as this, try the Rails mailing list,
> > at http://lists.rubyonrails.org/mailman/listinfo/rails or
> > http://www.ruby-forum.com/forum/3
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MVC Controller question - Calling one Controller from another Michael Earls ASP .Net 3 03-24-2009 02:12 AM
Calling Ctags within a rails model, controller, or view John Lynch Ruby 0 10-25-2006 03:05 PM
Correct way to use DRb within a Rails Controller? x1 Ruby 2 12-17-2005 03:27 AM
Calling a Web Service using Axis, from within an Axis Web Service running under Tomcat hocho888 Java 1 04-29-2005 08:26 PM
Calling an Asynch web service within a web service. Tony T. ASP .Net Web Services 0 04-25-2004 11:46 PM



Advertisments