0

我是 WSDL 的新手。 代码(我直接在视图中添加了 - 用于测试):(页面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

在控制器中:

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

当我尝试在控制台中运行它时,一切都很好,我可以看到,result.to_hash但是当我去时,http://0.0.0.0:3000/ccapis我得到了我上面提到的错误。

我要达到的目标的解释:我需要为客户提供一个 WSDL,该客户根据分数获取所有奖品。

如果我的方法有误,请指导我查看文档,以便我阅读并获得更好的理解。再次感谢。

4

0 回答 0