rubyjedi-actionwebservice 2.3.5.20100615120735
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +335 -0
- data/MIT-LICENSE +21 -0
- data/README +381 -0
- data/Rakefile +180 -0
- data/TODO +32 -0
- data/examples/googlesearch/README +143 -0
- data/examples/googlesearch/autoloading/google_search_api.rb +50 -0
- data/examples/googlesearch/autoloading/google_search_controller.rb +57 -0
- data/examples/googlesearch/delegated/google_search_service.rb +108 -0
- data/examples/googlesearch/delegated/search_controller.rb +7 -0
- data/examples/googlesearch/direct/google_search_api.rb +50 -0
- data/examples/googlesearch/direct/search_controller.rb +58 -0
- data/examples/metaWeblog/README +17 -0
- data/examples/metaWeblog/apis/blogger_api.rb +60 -0
- data/examples/metaWeblog/apis/blogger_service.rb +34 -0
- data/examples/metaWeblog/apis/meta_weblog_api.rb +67 -0
- data/examples/metaWeblog/apis/meta_weblog_service.rb +48 -0
- data/examples/metaWeblog/controllers/xmlrpc_controller.rb +16 -0
- data/generators/web_service/USAGE +28 -0
- data/generators/web_service/templates/api_definition.rb +5 -0
- data/generators/web_service/templates/controller.rb +8 -0
- data/generators/web_service/templates/functional_test.rb +19 -0
- data/generators/web_service/web_service_generator.rb +29 -0
- data/lib/action_web_service/acts_as_web_service.rb +24 -0
- data/lib/action_web_service/api.rb +297 -0
- data/lib/action_web_service/base.rb +38 -0
- data/lib/action_web_service/casting.rb +151 -0
- data/lib/action_web_service/client/base.rb +28 -0
- data/lib/action_web_service/client/soap_client.rb +113 -0
- data/lib/action_web_service/client/xmlrpc_client.rb +58 -0
- data/lib/action_web_service/client.rb +3 -0
- data/lib/action_web_service/container/action_controller_container.rb +93 -0
- data/lib/action_web_service/container/delegated_container.rb +86 -0
- data/lib/action_web_service/container/direct_container.rb +69 -0
- data/lib/action_web_service/container.rb +3 -0
- data/lib/action_web_service/dispatcher/abstract.rb +208 -0
- data/lib/action_web_service/dispatcher/action_controller_dispatcher.rb +396 -0
- data/lib/action_web_service/dispatcher.rb +2 -0
- data/lib/action_web_service/invocation.rb +202 -0
- data/lib/action_web_service/protocol/abstract.rb +112 -0
- data/lib/action_web_service/protocol/discovery.rb +37 -0
- data/lib/action_web_service/protocol/soap_protocol/marshaler.rb +242 -0
- data/lib/action_web_service/protocol/soap_protocol.rb +176 -0
- data/lib/action_web_service/protocol/xmlrpc_protocol.rb +123 -0
- data/lib/action_web_service/protocol.rb +4 -0
- data/lib/action_web_service/scaffolding.rb +281 -0
- data/lib/action_web_service/simple.rb +53 -0
- data/lib/action_web_service/string_to_datetime_for_soap.rb +16 -0
- data/lib/action_web_service/struct.rb +68 -0
- data/lib/action_web_service/support/class_inheritable_options.rb +26 -0
- data/lib/action_web_service/support/signature_types.rb +261 -0
- data/lib/action_web_service/templates/scaffolds/layout.html.erb +65 -0
- data/lib/action_web_service/templates/scaffolds/methods.html.erb +6 -0
- data/lib/action_web_service/templates/scaffolds/parameters.html.erb +29 -0
- data/lib/action_web_service/templates/scaffolds/result.html.erb +30 -0
- data/lib/action_web_service/test_invoke.rb +110 -0
- data/lib/action_web_service/version.rb +9 -0
- data/lib/action_web_service.rb +60 -0
- data/lib/actionwebservice.rb +1 -0
- data/setup.rb +1379 -0
- data/test/abstract_client.rb +184 -0
- data/test/abstract_dispatcher.rb +549 -0
- data/test/abstract_unit.rb +43 -0
- data/test/actionwebservice_unittest.db +0 -0
- data/test/api_test.rb +102 -0
- data/test/apis/auto_load_api.rb +3 -0
- data/test/apis/broken_auto_load_api.rb +2 -0
- data/test/base_test.rb +42 -0
- data/test/casting_test.rb +95 -0
- data/test/client_soap_test.rb +156 -0
- data/test/client_xmlrpc_test.rb +154 -0
- data/test/container_test.rb +75 -0
- data/test/debug.log +12305 -0
- data/test/dispatcher_action_controller_soap_test.rb +139 -0
- data/test/dispatcher_action_controller_xmlrpc_test.rb +59 -0
- data/test/fixtures/db_definitions/mysql.sql +8 -0
- data/test/fixtures/db_definitions/sqlite3.sql +8 -0
- data/test/fixtures/users.yml +12 -0
- data/test/gencov +3 -0
- data/test/invocation_test.rb +186 -0
- data/test/run +6 -0
- data/test/scaffolded_controller_test.rb +147 -0
- data/test/struct_test.rb +84 -0
- data/test/test_invoke_test.rb +113 -0
- metadata +182 -0
@@ -0,0 +1,184 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
require 'webrick'
|
3
|
+
require 'webrick/log'
|
4
|
+
require 'singleton'
|
5
|
+
|
6
|
+
module ClientTest
|
7
|
+
class Person < ActionWebService::Struct
|
8
|
+
member :firstnames, [:string]
|
9
|
+
member :lastname, :string
|
10
|
+
|
11
|
+
def ==(other)
|
12
|
+
firstnames == other.firstnames && lastname == other.lastname
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Inner < ActionWebService::Struct
|
17
|
+
member :name, :string
|
18
|
+
end
|
19
|
+
|
20
|
+
class Outer < ActionWebService::Struct
|
21
|
+
member :name, :string
|
22
|
+
member :inner, Inner
|
23
|
+
end
|
24
|
+
|
25
|
+
class User < ActiveRecord::Base
|
26
|
+
end
|
27
|
+
|
28
|
+
module Accounting
|
29
|
+
class User < ActiveRecord::Base
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class WithModel < ActionWebService::Struct
|
34
|
+
member :user, User
|
35
|
+
member :users, [User]
|
36
|
+
end
|
37
|
+
|
38
|
+
class WithMultiDimArray < ActionWebService::Struct
|
39
|
+
member :pref, [[:string]]
|
40
|
+
end
|
41
|
+
|
42
|
+
class API < ActionWebService::API::Base
|
43
|
+
api_method :void
|
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}]
|
51
|
+
api_method :thrower
|
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]
|
56
|
+
end
|
57
|
+
|
58
|
+
class NullLogOut
|
59
|
+
def <<(*args); end
|
60
|
+
end
|
61
|
+
|
62
|
+
class Container < ActionController::Base
|
63
|
+
acts_as_web_service
|
64
|
+
web_service_api API
|
65
|
+
|
66
|
+
attr_accessor :value_void
|
67
|
+
attr_accessor :value_normal
|
68
|
+
attr_accessor :value_array_return
|
69
|
+
attr_accessor :value_struct_pass
|
70
|
+
attr_accessor :value_named_parameters
|
71
|
+
|
72
|
+
def initialize
|
73
|
+
@value_void = nil
|
74
|
+
@value_normal = nil
|
75
|
+
@value_array_return = nil
|
76
|
+
@value_struct_pass = nil
|
77
|
+
@value_named_parameters = nil
|
78
|
+
end
|
79
|
+
|
80
|
+
def void
|
81
|
+
@value_void = @method_params
|
82
|
+
end
|
83
|
+
|
84
|
+
def normal
|
85
|
+
@value_normal = @method_params
|
86
|
+
5
|
87
|
+
end
|
88
|
+
|
89
|
+
def array_return
|
90
|
+
person = Person.new
|
91
|
+
person.firstnames = ["one", "two"]
|
92
|
+
person.lastname = "last"
|
93
|
+
@value_array_return = [person]
|
94
|
+
end
|
95
|
+
|
96
|
+
def struct_pass
|
97
|
+
@value_struct_pass = @method_params
|
98
|
+
true
|
99
|
+
end
|
100
|
+
|
101
|
+
def nil_struct_return
|
102
|
+
nil
|
103
|
+
end
|
104
|
+
|
105
|
+
def inner_nil
|
106
|
+
Outer.new :name => 'outer', :inner => nil
|
107
|
+
end
|
108
|
+
|
109
|
+
def client_container
|
110
|
+
50
|
111
|
+
end
|
112
|
+
|
113
|
+
def named_parameters
|
114
|
+
@value_named_parameters = @method_params
|
115
|
+
end
|
116
|
+
|
117
|
+
def thrower
|
118
|
+
raise "Hi"
|
119
|
+
end
|
120
|
+
|
121
|
+
def user_return
|
122
|
+
User.find(1)
|
123
|
+
end
|
124
|
+
|
125
|
+
def with_model_return
|
126
|
+
WithModel.new :user => User.find(1), :users => User.find(:all)
|
127
|
+
end
|
128
|
+
|
129
|
+
def scoped_model_return
|
130
|
+
Accounting::User.find(1)
|
131
|
+
end
|
132
|
+
|
133
|
+
def multi_dim_return
|
134
|
+
WithMultiDimArray.new :pref => [%w{pref1 value1}, %w{pref2 value2}]
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
class AbstractClientLet < WEBrick::HTTPServlet::AbstractServlet
|
139
|
+
def initialize(controller)
|
140
|
+
@controller = controller
|
141
|
+
end
|
142
|
+
|
143
|
+
def get_instance(*args)
|
144
|
+
self
|
145
|
+
end
|
146
|
+
|
147
|
+
def require_path_info?
|
148
|
+
false
|
149
|
+
end
|
150
|
+
|
151
|
+
def do_GET(req, res)
|
152
|
+
raise WEBrick::HTTPStatus::MethodNotAllowed, "GET request not allowed."
|
153
|
+
end
|
154
|
+
|
155
|
+
def do_POST(req, res)
|
156
|
+
raise NotImplementedError
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
class AbstractServer
|
161
|
+
include ClientTest
|
162
|
+
include Singleton
|
163
|
+
attr :container
|
164
|
+
def initialize
|
165
|
+
@container = Container.new
|
166
|
+
@clientlet = create_clientlet(@container)
|
167
|
+
log = WEBrick::BasicLog.new(NullLogOut.new)
|
168
|
+
@server = WEBrick::HTTPServer.new(:Port => server_port, :Logger => log, :AccessLog => [])
|
169
|
+
@server.mount('/', @clientlet)
|
170
|
+
@thr = Thread.new { @server.start }
|
171
|
+
until @server.status == :Running; end
|
172
|
+
at_exit { @server.stop; @thr.join }
|
173
|
+
end
|
174
|
+
|
175
|
+
protected
|
176
|
+
def create_clientlet
|
177
|
+
raise NotImplementedError
|
178
|
+
end
|
179
|
+
|
180
|
+
def server_port
|
181
|
+
raise NotImplementedError
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|