Ruby on rails 3 rest应用程序中的链接

Ruby on rails 3 rest应用程序中的链接,ruby-on-rails-3,rest,hyperlink,Ruby On Rails 3,Rest,Hyperlink,我正在使用ruby 1.9.2、rails 3.2.1和mysql,我有一个rest应用程序,但是链接不起作用,当我转到localhost:3000时,我得到: 以下是代码: my view.html.erb 我的控制器: root :to => 'ws#inicio' # See how all your routes lay out with "rake routes" # This is a legacy wild controller route that's not

我正在使用ruby 1.9.2、rails 3.2.1和mysql,我有一个rest应用程序,但是链接不起作用,当我转到localhost:3000时,我得到:

以下是代码:

my view.html.erb

我的控制器:

root :to => 'ws#inicio'


  # See how all your routes lay out with "rake routes"

  # This is a legacy wild controller route that's not recommended for RESTful applications.
  # Note: This route will make all actions in every controller accessible via GET requests.
   match ':controller(/:action(/:id))(.:format)'
end
require 'savon'

class WsController < ApplicationController   def inicio   end

  def login
    data = {"Version" => "xx",
      "CodEmpresa" => "xx",
      "Rut" => "1579xxxxx-x",
      "Clave" => "xxxx",
      "SO" => "xx",
      "Tipodispositivo" => "xx"}

    response = get_result("loteria_autentificacion", data)

    render :text => response


       end

  def registro
    data = {"Version" => "01",
      "CodEmpresa" => "01",
      "CodAgente" => "01",
      "Rut" => "1579xxxxx-x",
      "email" => "xxxx@xxxxxxx.com",
      "Clave" => "xxxx",
      "SO" => "xx",
      "Tipodispositivo" => "xx"}

    response = get_result("loteria_registro", data)

    render :xml => response   end

  def get_result(service, data)
    client = Savon::Client.new do
      wsdl.document = File.expand_path("#{Rails.root}/doc/#{service}.wsdl", __FILE__)
    end

    response = client.request :wsdl, service do
      soap.body = data
    end

    return response.to_xml   end end
需要“savon”
类WsController<应用程序控制器定义inicio end
def登录
数据={“版本”=>“xx”,
“CodEmpresa”=>“xx”,
“车辙”=>“1579xxxxx-x”,
“Clave”=>“xxxx”,
“SO”=>“xx”,
“Tipodispositivo”=>“xx”}
响应=获取结果(“loteria\U AUTITICION”,数据)
render:text=>response
结束
def注册表
数据={“版本”=>“01”,
“CodEmpresa”=>“01”,
“CodAgente”=>“01”,
“车辙”=>“1579xxxxx-x”,
“电子邮件”=>”xxxx@xxxxxxx.com",
“Clave”=>“xxxx”,
“SO”=>“xx”,
“Tipodispositivo”=>“xx”}
响应=获取结果(“loteria\u registro”,数据)
render:xml=>响应结束
def get_结果(服务、数据)
client=Savon::client.new do
wsdl.document=File.expand_path(“#{Rails.root}/doc/#{service}.wsdl”,#u File#
结束
response=client.request:wsdl,服务do
soap.body=数据
结束
返回response.to_xml end

代码中的这一行,
wsdl.document=File.expand_path(“#{Rails.root}/doc/#{service}.wsdl”)
告诉savon在“C:/Ruby192/PROYECTOS/loteriab/doc/loteria_registro.wsdl”中查找wsdl


错误是WSDL文件loteria_registro.WSDL不是代码行指定的位置。下载WSD并将其放在那里,或者更改
wsdl.document
以指向Web服务。

@suely Great!继续并点击复选标记,然后如果这解决了问题
root :to => 'ws#inicio'


  # See how all your routes lay out with "rake routes"

  # This is a legacy wild controller route that's not recommended for RESTful applications.
  # Note: This route will make all actions in every controller accessible via GET requests.
   match ':controller(/:action(/:id))(.:format)'
end
require 'savon'

class WsController < ApplicationController   def inicio   end

  def login
    data = {"Version" => "xx",
      "CodEmpresa" => "xx",
      "Rut" => "1579xxxxx-x",
      "Clave" => "xxxx",
      "SO" => "xx",
      "Tipodispositivo" => "xx"}

    response = get_result("loteria_autentificacion", data)

    render :text => response


       end

  def registro
    data = {"Version" => "01",
      "CodEmpresa" => "01",
      "CodAgente" => "01",
      "Rut" => "1579xxxxx-x",
      "email" => "xxxx@xxxxxxx.com",
      "Clave" => "xxxx",
      "SO" => "xx",
      "Tipodispositivo" => "xx"}

    response = get_result("loteria_registro", data)

    render :xml => response   end

  def get_result(service, data)
    client = Savon::Client.new do
      wsdl.document = File.expand_path("#{Rails.root}/doc/#{service}.wsdl", __FILE__)
    end

    response = client.request :wsdl, service do
      soap.body = data
    end

    return response.to_xml   end end