LirenZhao's Blog

C0#1J0a1v0a1r0u0b1y0r1a1i1ls0f0l0e0x01
gtalk:lirnzhao#gmail.com
随笔 - 42, 文章 - 0, 评论 - 46, 引用 - 1
数据加载中……

RoR: Ruby On Rails 的 Web Service 2 使用before_invocation进行验证调用权限

使用before_invocation进行验证调用权限

API
class BlogApi < ActionWebService::API::Base
  api_method :hello_world,
  :expects 
=> [{"password" => :string},{"user" => :string}],
  :returns 
=> [:string]
end

Controller
class BlogController < ApplicationController
  wsdl_service_name 'Blog'
  web_service_api BlogApi
  wsdl_namespace 'http://www.somewhere.com' #web service的名字空间
  web_service_scaffold :invoke
  before_invocation :login #指定拦截的方法名称
  
  def hello_world(pass,user)
    
"hello #{user}"
  end  
  
  protected 
  def login(methodname,args) #参数为被拦截函数名,被拦截函数参数数组
    raise 
"Method #{methodname} Not authenticated" unless args[0== 'srcret'
  end
end


posted on 2007-05-14 10:33 LirenZhao 阅读(215) 评论(1)  编辑 收藏 所属分类: Ruby On Rails

评论

#1楼    回复  引用    

还没有涉及到这部分,先Mark一下。
2007-06-22 17:29 | Ruby中国 [未注册用户]

标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2007-05-16 14:47 编辑过
"五向定位"职业成长路线公开课(上海、南京、大连)
Google站内搜索


相关链接: