1 require File.dirname(__FILE__) + '/abstract_unit'
7 class Person < ActionWebService::Struct
8 member :firstnames, [:string]
9 member :lastname, :string
12 firstnames == other.firstnames && lastname == other.lastname
16 class Inner < ActionWebService::Struct
20 class Outer < ActionWebService::Struct
25 class User < ActiveRecord::Base
29 class User < ActiveRecord::Base
33 class WithModel < ActionWebService::Struct
38 class WithMultiDimArray < ActionWebService::Struct
39 member :pref, [[:string]]
42 class API < ActionWebService::API::Base
44 api_method :normal, :expects => [:int, :int], :returns => [:int]
45 api_method :array_return, :returns => [[Person]]
46 api_method :struct_pass, :expects => [[Person]], :returns => [:bool]
47 api_method :nil_struct_return, :returns => [Person]
48 api_method :inner_nil, :returns => [Outer]
49 api_method :client_container, :returns => [:int]
50 api_method :named_parameters, :expects => [{:key=>:string}, {:id=>:int}]
52 api_method :user_return, :returns => [User]
53 api_method :with_model_return, :returns => [WithModel]
54 api_method :scoped_model_return, :returns => [Accounting::User]
55 api_method :multi_dim_return, :returns => [WithMultiDimArray]
62 class Container < ActionController::Base
65 attr_accessor :value_void
66 attr_accessor :value_normal
67 attr_accessor :value_array_return
68 attr_accessor :value_struct_pass
69 attr_accessor :value_named_parameters
74 @value_array_return = nil
75 @value_struct_pass = nil
76 @value_named_parameters = nil
80 @value_void = @method_params
84 @value_normal = @method_params
90 person.firstnames = ["one", "two"]
91 person.lastname = "last"
92 @value_array_return = [person]
96 @value_struct_pass = @method_params
100 def nil_struct_return
105 Outer.new :name => 'outer', :inner => nil
113 @value_named_parameters = @method_params
124 def with_model_return
125 WithModel.new :user => User.find(1), :users => User.find(:all)
128 def scoped_model_return
129 Accounting::User.find(1)
133 WithMultiDimArray.new :pref => [%w{pref1 value1}, %w{pref2 value2}]
137 class AbstractClientLet < WEBrick::HTTPServlet::AbstractServlet
138 def initialize(controller)
139 @controller = controller
142 def get_instance(*args)
146 def require_path_info?
151 raise WEBrick::HTTPStatus::MethodNotAllowed, "GET request not allowed."
154 def do_POST(req, res)
155 raise NotImplementedError
164 @container = Container.new
165 @clientlet = create_clientlet(@container)
166 log = WEBrick::BasicLog.new(NullLogOut.new)
167 @server = WEBrick::HTTPServer.new(:Port => server_port, :Logger => log, :AccessLog => log)
168 @server.mount('/', @clientlet)
169 @thr = Thread.new { @server.start }
170 until @server.status == :Running; end
171 at_exit { @server.stop; @thr.join }
176 raise NotImplementedError
180 raise NotImplementedError