Error calling a SOAP service from within a Rails controller

Discussion in 'Ruby' started by Dean Holdren, Jan 26, 2006.

  1. Dean Holdren

    Dean Holdren Guest

    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,
    :pop12 =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_driver
    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,
    :pop12 =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_driver
    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
    ***************************************************************************=
    *******************
    Dean Holdren, Jan 26, 2006
    #1
    1. Advertising

  2. Anthony Elizondo, Jan 26, 2006
    #2
    1. Advertising

  3. Dean Holdren

    Dean Holdren Guest

    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=09:pop12 =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 :pop12, :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 <> wrote:
    > When you're playing with SOAP in Rails, I think you want to use
    > ActionWebService. See:
    > http://rails.rubyonrails.com/classes/ActionWebService/Client/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
    >
    Dean Holdren, Jan 26, 2006
    #3
  4. Dean Holdren

    Dean Holdren Guest

    well it turns out I was passing bad parameters to the service. weird
    response though...

    On 1/26/06, Dean Holdren <> 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,
    > :pop12 =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 :pop12, :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 <> wrote:
    > > When you're playing with SOAP in Rails, I think you want to use
    > > ActionWebService. See:
    > > http://rails.rubyonrails.com/classes/ActionWebService/Client/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
    > >

    >
    >
    Dean Holdren, Jan 28, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brad Clements
    Replies:
    0
    Views:
    634
    Brad Clements
    Aug 19, 2003
  2. Brad Clements
    Replies:
    3
    Views:
    7,316
    Brad Clements
    Aug 24, 2003
  3. Michael Earls
    Replies:
    3
    Views:
    3,241
    MBUnit
    Mar 24, 2009
  4. x1
    Replies:
    2
    Views:
    104
  5. John Lynch
    Replies:
    0
    Views:
    110
    John Lynch
    Oct 25, 2006
Loading...

Share This Page