0

I am new to WSDL. Code (I have added in the view directly - for test): (Page: http://localhost:3000/ccapis )

   require 'savon'
   client = Savon::Client.new(wsdl: "http://localhost:3000/ccapis/wsdl")
   result = client.call(:fetch_prizes, message: { :gl_id => "123456789" })
   result.to_hash

And in the controller:

soap_action "fetch_prizes",
              :args   =>  { :gl_id => :string },
              :return => [:array]
  def fetch_prizes
        glnumber = params[:gl_id ]
        prize = Prize.where(:gl_id  => glnumber)
        prize_to_show = []
        a_hash = {}
        prize.each do |p|
            a_hash = { :prize => p.prize.to_s, :score => p.score.to_s, :date => p.round_date.to_s }
            prize_to_show.push  a_hash
            a_hash = nil
        end
      render :soap => prize_to_show
  end

When I try and run this in the Console all are good and I can see the result.to_hash but when I go to http://0.0.0.0:3000/ccapis I get the error that I mentioned above.

Explanation of what I am trying to achieve: I need to supply a WSDL for a client which fetches all the prizes based on a score.

If My approach is wrong please direct me to a document so I can have a read and get a better understanding. Thanks again.

Mr H
  • 5,254
  • 3
  • 38
  • 43
  • What is the "washout gem"? I see you are using [Savon](https://github.com/savonrb/savon). I'd move your code that works to a model class, then call that code from the console. Keep in mind you're interacting with a HTTP service so you may have to handle HTTP timeouts, exceptions etc. – Andrew Atkinson Jun 03 '14 at 03:30
  • https://github.com/inossidabile/wash_out is generating WSDL, and SAVON consume it. So in my app I need to consume the SOAP from client server and I need to generate SOAP based on client request. Cheers – Mr H Jun 03 '14 at 03:38
  • I see. I think more debugging information is needed to figure out why "result" was nil. I'd suggest adding [pry](https://github.com/pry/pry) to your project, adding a `binding.pry` where you expect the first problem to be, and to start debugging each line. You could also look for an example project with washout and savon that works, and compare what is different about your code. – Andrew Atkinson Jun 03 '14 at 14:37

0 Answers0