休息应用中的链接

时间:2012-02-09 18:34:26

标签: ruby-on-rails-3 rest hyperlink

我正在使用ruby 1.9.2,rails 3.2.1和mysql,我有一个休息应用程序,但链接不起作用,当我去localhost:3000我得到:

Errno::ENOENT in WsController#registro

No such file or directory - C:/Ruby192/PROYECTOS/loteriab/doc/loteria_registro.wsdl
Rails.root: C:/Ruby192/PROYECTOS/loteriab

Application Trace | Framework Trace | Full Trace
app/controllers/ws_controller.rb:43:in `get_result'
app/controllers/ws_controller.rb:33:in `registro'

这是代码:

我的view.html.erb

> <div id="menu">         <ul>            <li>            <%= link_to "login", root_path %><p
> >es el proceso mediante el cual se controla el acceso individual al webservice de loteria mediante la identificación del usuario
> utilizando credenciales provistas por el usuarioUn usuario</p>          <%=
> link_to "registro", root_path %>
>         
>         
> 
>             <%= link_to " login ", "ws/registro"  %>
>              </li>      </ul>   </div>

我的路线:

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

1 个答案:

答案 0 :(得分:0)

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

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