reidiculous-actionwebservice 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (195) hide show
  1. data/CHANGELOG +320 -0
  2. data/MIT-LICENSE +21 -0
  3. data/README +381 -0
  4. data/Rakefile +180 -0
  5. data/TODO +32 -0
  6. data/examples/googlesearch/autoloading/google_search_api.rb +50 -0
  7. data/examples/googlesearch/autoloading/google_search_controller.rb +57 -0
  8. data/examples/googlesearch/delegated/google_search_service.rb +108 -0
  9. data/examples/googlesearch/delegated/search_controller.rb +7 -0
  10. data/examples/googlesearch/direct/google_search_api.rb +50 -0
  11. data/examples/googlesearch/direct/search_controller.rb +58 -0
  12. data/examples/metaWeblog/apis/blogger_api.rb +60 -0
  13. data/examples/metaWeblog/apis/blogger_service.rb +34 -0
  14. data/examples/metaWeblog/apis/meta_weblog_api.rb +67 -0
  15. data/examples/metaWeblog/apis/meta_weblog_service.rb +48 -0
  16. data/examples/metaWeblog/controllers/xmlrpc_controller.rb +16 -0
  17. data/generators/web_service/USAGE +28 -0
  18. data/generators/web_service/templates/api_definition.rb +5 -0
  19. data/generators/web_service/templates/controller.rb +8 -0
  20. data/generators/web_service/templates/functional_test.rb +19 -0
  21. data/generators/web_service/web_service_generator.rb +29 -0
  22. data/lib/action_web_service.rb +71 -0
  23. data/lib/action_web_service/api.rb +297 -0
  24. data/lib/action_web_service/base.rb +38 -0
  25. data/lib/action_web_service/casting.rb +149 -0
  26. data/lib/action_web_service/client.rb +3 -0
  27. data/lib/action_web_service/client/base.rb +28 -0
  28. data/lib/action_web_service/client/soap_client.rb +113 -0
  29. data/lib/action_web_service/client/xmlrpc_client.rb +58 -0
  30. data/lib/action_web_service/container.rb +3 -0
  31. data/lib/action_web_service/container/action_controller_container.rb +93 -0
  32. data/lib/action_web_service/container/delegated_container.rb +86 -0
  33. data/lib/action_web_service/container/direct_container.rb +69 -0
  34. data/lib/action_web_service/dispatcher.rb +2 -0
  35. data/lib/action_web_service/dispatcher/abstract.rb +207 -0
  36. data/lib/action_web_service/dispatcher/action_controller_dispatcher.rb +379 -0
  37. data/lib/action_web_service/invocation.rb +202 -0
  38. data/lib/action_web_service/protocol.rb +4 -0
  39. data/lib/action_web_service/protocol/abstract.rb +115 -0
  40. data/lib/action_web_service/protocol/discovery.rb +37 -0
  41. data/lib/action_web_service/protocol/soap_protocol.rb +176 -0
  42. data/lib/action_web_service/protocol/soap_protocol/marshaler.rb +242 -0
  43. data/lib/action_web_service/protocol/xmlrpc_protocol.rb +122 -0
  44. data/lib/action_web_service/scaffolding.rb +281 -0
  45. data/lib/action_web_service/soap/attachment.rb +107 -0
  46. data/lib/action_web_service/soap/baseData.rb +942 -0
  47. data/lib/action_web_service/soap/element.rb +258 -0
  48. data/lib/action_web_service/soap/encodingstyle/aspDotNetHandler.rb +213 -0
  49. data/lib/action_web_service/soap/encodingstyle/handler.rb +100 -0
  50. data/lib/action_web_service/soap/encodingstyle/literalHandler.rb +226 -0
  51. data/lib/action_web_service/soap/encodingstyle/soapHandler.rb +582 -0
  52. data/lib/action_web_service/soap/generator.rb +268 -0
  53. data/lib/action_web_service/soap/header/handler.rb +57 -0
  54. data/lib/action_web_service/soap/header/handlerset.rb +70 -0
  55. data/lib/action_web_service/soap/header/simplehandler.rb +44 -0
  56. data/lib/action_web_service/soap/httpconfigloader.rb +119 -0
  57. data/lib/action_web_service/soap/mapping.rb +10 -0
  58. data/lib/action_web_service/soap/mapping/factory.rb +355 -0
  59. data/lib/action_web_service/soap/mapping/mapping.rb +381 -0
  60. data/lib/action_web_service/soap/mapping/registry.rb +541 -0
  61. data/lib/action_web_service/soap/mapping/rubytypeFactory.rb +475 -0
  62. data/lib/action_web_service/soap/mapping/typeMap.rb +50 -0
  63. data/lib/action_web_service/soap/mapping/wsdlencodedregistry.rb +280 -0
  64. data/lib/action_web_service/soap/mapping/wsdlliteralregistry.rb +418 -0
  65. data/lib/action_web_service/soap/marshal.rb +59 -0
  66. data/lib/action_web_service/soap/mimemessage.rb +240 -0
  67. data/lib/action_web_service/soap/netHttpClient.rb +190 -0
  68. data/lib/action_web_service/soap/parser.rb +251 -0
  69. data/lib/action_web_service/soap/processor.rb +66 -0
  70. data/lib/action_web_service/soap/property.rb +333 -0
  71. data/lib/action_web_service/soap/rpc/cgistub.rb +206 -0
  72. data/lib/action_web_service/soap/rpc/driver.rb +254 -0
  73. data/lib/action_web_service/soap/rpc/element.rb +325 -0
  74. data/lib/action_web_service/soap/rpc/httpserver.rb +129 -0
  75. data/lib/action_web_service/soap/rpc/proxy.rb +497 -0
  76. data/lib/action_web_service/soap/rpc/router.rb +594 -0
  77. data/lib/action_web_service/soap/rpc/rpc.rb +25 -0
  78. data/lib/action_web_service/soap/rpc/soaplet.rb +162 -0
  79. data/lib/action_web_service/soap/rpc/standaloneServer.rb +43 -0
  80. data/lib/action_web_service/soap/soap.rb +140 -0
  81. data/lib/action_web_service/soap/streamHandler.rb +229 -0
  82. data/lib/action_web_service/soap/wsdlDriver.rb +575 -0
  83. data/lib/action_web_service/struct.rb +64 -0
  84. data/lib/action_web_service/support/class_inheritable_options.rb +28 -0
  85. data/lib/action_web_service/support/signature_types.rb +227 -0
  86. data/lib/action_web_service/test_invoke.rb +110 -0
  87. data/lib/action_web_service/version.rb +9 -0
  88. data/lib/action_web_service/wsdl/binding.rb +65 -0
  89. data/lib/action_web_service/wsdl/data.rb +64 -0
  90. data/lib/action_web_service/wsdl/definitions.rb +250 -0
  91. data/lib/action_web_service/wsdl/documentation.rb +32 -0
  92. data/lib/action_web_service/wsdl/import.rb +80 -0
  93. data/lib/action_web_service/wsdl/importer.rb +38 -0
  94. data/lib/action_web_service/wsdl/info.rb +39 -0
  95. data/lib/action_web_service/wsdl/message.rb +54 -0
  96. data/lib/action_web_service/wsdl/operation.rb +130 -0
  97. data/lib/action_web_service/wsdl/operationBinding.rb +108 -0
  98. data/lib/action_web_service/wsdl/param.rb +85 -0
  99. data/lib/action_web_service/wsdl/parser.rb +163 -0
  100. data/lib/action_web_service/wsdl/part.rb +52 -0
  101. data/lib/action_web_service/wsdl/port.rb +84 -0
  102. data/lib/action_web_service/wsdl/portType.rb +73 -0
  103. data/lib/action_web_service/wsdl/service.rb +61 -0
  104. data/lib/action_web_service/wsdl/soap/address.rb +40 -0
  105. data/lib/action_web_service/wsdl/soap/binding.rb +49 -0
  106. data/lib/action_web_service/wsdl/soap/body.rb +56 -0
  107. data/lib/action_web_service/wsdl/soap/cgiStubCreator.rb +76 -0
  108. data/lib/action_web_service/wsdl/soap/classDefCreator.rb +314 -0
  109. data/lib/action_web_service/wsdl/soap/classDefCreatorSupport.rb +126 -0
  110. data/lib/action_web_service/wsdl/soap/clientSkeltonCreator.rb +78 -0
  111. data/lib/action_web_service/wsdl/soap/complexType.rb +161 -0
  112. data/lib/action_web_service/wsdl/soap/data.rb +42 -0
  113. data/lib/action_web_service/wsdl/soap/definitions.rb +149 -0
  114. data/lib/action_web_service/wsdl/soap/driverCreator.rb +95 -0
  115. data/lib/action_web_service/wsdl/soap/element.rb +28 -0
  116. data/lib/action_web_service/wsdl/soap/fault.rb +56 -0
  117. data/lib/action_web_service/wsdl/soap/header.rb +86 -0
  118. data/lib/action_web_service/wsdl/soap/headerfault.rb +56 -0
  119. data/lib/action_web_service/wsdl/soap/mappingRegistryCreator.rb +92 -0
  120. data/lib/action_web_service/wsdl/soap/methodDefCreator.rb +228 -0
  121. data/lib/action_web_service/wsdl/soap/operation.rb +122 -0
  122. data/lib/action_web_service/wsdl/soap/servantSkeltonCreator.rb +67 -0
  123. data/lib/action_web_service/wsdl/soap/standaloneServerStubCreator.rb +85 -0
  124. data/lib/action_web_service/wsdl/soap/wsdl2ruby.rb +176 -0
  125. data/lib/action_web_service/wsdl/types.rb +43 -0
  126. data/lib/action_web_service/wsdl/wsdl.rb +23 -0
  127. data/lib/action_web_service/wsdl/xmlSchema/all.rb +69 -0
  128. data/lib/action_web_service/wsdl/xmlSchema/annotation.rb +34 -0
  129. data/lib/action_web_service/wsdl/xmlSchema/any.rb +56 -0
  130. data/lib/action_web_service/wsdl/xmlSchema/attribute.rb +127 -0
  131. data/lib/action_web_service/wsdl/xmlSchema/choice.rb +69 -0
  132. data/lib/action_web_service/wsdl/xmlSchema/complexContent.rb +92 -0
  133. data/lib/action_web_service/wsdl/xmlSchema/complexType.rb +139 -0
  134. data/lib/action_web_service/wsdl/xmlSchema/content.rb +96 -0
  135. data/lib/action_web_service/wsdl/xmlSchema/data.rb +80 -0
  136. data/lib/action_web_service/wsdl/xmlSchema/element.rb +154 -0
  137. data/lib/action_web_service/wsdl/xmlSchema/enumeration.rb +36 -0
  138. data/lib/action_web_service/wsdl/xmlSchema/import.rb +65 -0
  139. data/lib/action_web_service/wsdl/xmlSchema/importer.rb +87 -0
  140. data/lib/action_web_service/wsdl/xmlSchema/include.rb +54 -0
  141. data/lib/action_web_service/wsdl/xmlSchema/length.rb +35 -0
  142. data/lib/action_web_service/wsdl/xmlSchema/parser.rb +166 -0
  143. data/lib/action_web_service/wsdl/xmlSchema/pattern.rb +36 -0
  144. data/lib/action_web_service/wsdl/xmlSchema/schema.rb +143 -0
  145. data/lib/action_web_service/wsdl/xmlSchema/sequence.rb +69 -0
  146. data/lib/action_web_service/wsdl/xmlSchema/simpleContent.rb +65 -0
  147. data/lib/action_web_service/wsdl/xmlSchema/simpleExtension.rb +54 -0
  148. data/lib/action_web_service/wsdl/xmlSchema/simpleRestriction.rb +73 -0
  149. data/lib/action_web_service/wsdl/xmlSchema/simpleType.rb +73 -0
  150. data/lib/action_web_service/wsdl/xmlSchema/unique.rb +34 -0
  151. data/lib/action_web_service/wsdl/xmlSchema/xsd2ruby.rb +107 -0
  152. data/lib/action_web_service/xsd/charset.rb +187 -0
  153. data/lib/action_web_service/xsd/codegen.rb +12 -0
  154. data/lib/action_web_service/xsd/codegen/classdef.rb +203 -0
  155. data/lib/action_web_service/xsd/codegen/commentdef.rb +34 -0
  156. data/lib/action_web_service/xsd/codegen/gensupport.rb +166 -0
  157. data/lib/action_web_service/xsd/codegen/methoddef.rb +63 -0
  158. data/lib/action_web_service/xsd/codegen/moduledef.rb +191 -0
  159. data/lib/action_web_service/xsd/datatypes.rb +1269 -0
  160. data/lib/action_web_service/xsd/datatypes1999.rb +20 -0
  161. data/lib/action_web_service/xsd/iconvcharset.rb +33 -0
  162. data/lib/action_web_service/xsd/mapping.rb +42 -0
  163. data/lib/action_web_service/xsd/namedelements.rb +95 -0
  164. data/lib/action_web_service/xsd/ns.rb +140 -0
  165. data/lib/action_web_service/xsd/qname.rb +78 -0
  166. data/lib/action_web_service/xsd/xmlparser.rb +61 -0
  167. data/lib/action_web_service/xsd/xmlparser/parser.rb +96 -0
  168. data/lib/action_web_service/xsd/xmlparser/rexmlparser.rb +54 -0
  169. data/lib/action_web_service/xsd/xmlparser/xmlparser.rb +50 -0
  170. data/lib/action_web_service/xsd/xmlparser/xmlscanner.rb +147 -0
  171. data/lib/actionwebservice.rb +1 -0
  172. data/setup.rb +1379 -0
  173. data/test/abstract_client.rb +183 -0
  174. data/test/abstract_dispatcher.rb +548 -0
  175. data/test/abstract_unit.rb +45 -0
  176. data/test/api_test.rb +103 -0
  177. data/test/apis/auto_load_api.rb +3 -0
  178. data/test/apis/broken_auto_load_api.rb +2 -0
  179. data/test/base_test.rb +42 -0
  180. data/test/casting_test.rb +95 -0
  181. data/test/client_soap_test.rb +156 -0
  182. data/test/client_xmlrpc_test.rb +153 -0
  183. data/test/container_test.rb +73 -0
  184. data/test/dispatcher_action_controller_soap_test.rb +139 -0
  185. data/test/dispatcher_action_controller_xmlrpc_test.rb +59 -0
  186. data/test/fixtures/db_definitions/mysql.sql +8 -0
  187. data/test/fixtures/db_definitions/sqlite3.sql +8 -0
  188. data/test/fixtures/users.yml +12 -0
  189. data/test/gencov +3 -0
  190. data/test/invocation_test.rb +185 -0
  191. data/test/run +6 -0
  192. data/test/scaffolded_controller_test.rb +146 -0
  193. data/test/struct_test.rb +52 -0
  194. data/test/test_invoke_test.rb +112 -0
  195. metadata +281 -0
@@ -0,0 +1,180 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+ require 'rake/rdoctask'
5
+ require 'rake/packagetask'
6
+ require 'rake/gempackagetask'
7
+ require 'rake/contrib/rubyforgepublisher'
8
+ require 'fileutils'
9
+ require File.join(File.dirname(__FILE__), 'lib', 'action_web_service', 'version')
10
+
11
+ PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
12
+ PKG_NAME = 'actionwebservice'
13
+ PKG_VERSION = ActionWebService::VERSION::STRING + PKG_BUILD
14
+ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
15
+ PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
16
+
17
+ RELEASE_NAME = "REL #{PKG_VERSION}"
18
+
19
+ RUBY_FORGE_PROJECT = "aws"
20
+ RUBY_FORGE_USER = "webster132"
21
+
22
+ desc "Default Task"
23
+ task :default => [ :test ]
24
+
25
+
26
+ # Run the unit tests
27
+ Rake::TestTask.new { |t|
28
+ t.libs << "test"
29
+ t.test_files = Dir['test/*_test.rb']
30
+ t.verbose = true
31
+ }
32
+
33
+ SCHEMA_PATH = File.join(File.dirname(__FILE__), *%w(test fixtures db_definitions))
34
+
35
+ desc 'Build the MySQL test database'
36
+ task :build_database do
37
+ %x( mysqladmin -uroot create actionwebservice_unittest )
38
+ %x( mysql -uroot actionwebservice_unittest < #{File.join(SCHEMA_PATH, 'mysql.sql')} )
39
+ end
40
+
41
+ desc 'Build the sqlite3 test database'
42
+ task :build_sqlite3_database do
43
+ filename = 'actionwebservice_unittest.db'
44
+ File.delete filename if File.exist? filename
45
+ %x(sqlite3 #{filename} < #{File.join(SCHEMA_PATH, 'sqlite3.sql')})
46
+ end
47
+
48
+
49
+ # Generate the RDoc documentation
50
+ Rake::RDocTask.new { |rdoc|
51
+ rdoc.rdoc_dir = 'doc'
52
+ rdoc.title = "Action Web Service -- Web services for Action Pack"
53
+ rdoc.options << '--line-numbers' << '--inline-source'
54
+ rdoc.options << '--charset' << 'utf-8'
55
+ rdoc.template = "#{ENV['template']}.rb" if ENV['template']
56
+ rdoc.rdoc_files.include('README')
57
+ rdoc.rdoc_files.include('CHANGELOG')
58
+ rdoc.rdoc_files.include('lib/action_web_service.rb')
59
+ rdoc.rdoc_files.include('lib/action_web_service/*.rb')
60
+ rdoc.rdoc_files.include('lib/action_web_service/api/*.rb')
61
+ rdoc.rdoc_files.include('lib/action_web_service/client/*.rb')
62
+ rdoc.rdoc_files.include('lib/action_web_service/container/*.rb')
63
+ rdoc.rdoc_files.include('lib/action_web_service/dispatcher/*.rb')
64
+ rdoc.rdoc_files.include('lib/action_web_service/protocol/*.rb')
65
+ rdoc.rdoc_files.include('lib/action_web_service/support/*.rb')
66
+ }
67
+
68
+
69
+ # Create compressed packages
70
+ spec = Gem::Specification.new do |s|
71
+ s.platform = Gem::Platform::RUBY
72
+ s.name = PKG_NAME
73
+ s.summary = "Web service support for Action Pack."
74
+ s.description = %q{Adds WSDL/SOAP and XML-RPC web service support to Action Pack}
75
+ s.version = PKG_VERSION
76
+
77
+ s.author = "Leon Breedt, Kent Sibilev"
78
+ s.email = "bitserf@gmail.com, ksibilev@yahoo.com"
79
+ s.rubyforge_project = "aws"
80
+ s.homepage = "http://www.rubyonrails.org"
81
+
82
+ s.add_dependency('actionpack', '= 2.3.5' + PKG_BUILD)
83
+ s.add_dependency('activerecord', '= 2.3.5' + PKG_BUILD)
84
+
85
+ s.has_rdoc = true
86
+ s.requirements << 'none'
87
+ s.require_path = 'lib'
88
+ s.autorequire = 'actionwebservice'
89
+
90
+ s.files = [ "Rakefile", "setup.rb", "README", "TODO", "CHANGELOG", "MIT-LICENSE" ]
91
+ s.files = s.files + Dir.glob( "examples/**/*" ).delete_if { |item| item.match( /\.(svn|git)/ ) }
92
+ s.files = s.files + Dir.glob( "lib/**/*" ).delete_if { |item| item.match( /\.(svn|git)/ ) }
93
+ s.files = s.files + Dir.glob( "test/**/*" ).delete_if { |item| item.match( /\.(svn|git)/ ) }
94
+ s.files = s.files + Dir.glob( "generators/**/*" ).delete_if { |item| item.match( /\.(svn|git)/ ) }
95
+ end
96
+ Rake::GemPackageTask.new(spec) do |p|
97
+ p.gem_spec = spec
98
+ p.need_tar = true
99
+ p.need_zip = true
100
+ end
101
+
102
+
103
+ # Publish beta gem
104
+ desc "Publish the API documentation"
105
+ task :pgem => [:package] do
106
+ Rake::SshFilePublisher.new("davidhh@wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
107
+ `ssh davidhh@wrath.rubyonrails.org './gemupdate.sh'`
108
+ end
109
+
110
+ # Publish documentation
111
+ desc "Publish the API documentation"
112
+ task :pdoc => [:rdoc] do
113
+ Rake::SshDirPublisher.new("davidhh@wrath.rubyonrails.org", "public_html/aws", "doc").upload
114
+ end
115
+
116
+
117
+ def each_source_file(*args)
118
+ prefix, includes, excludes, open_file = args
119
+ prefix ||= File.dirname(__FILE__)
120
+ open_file = true if open_file.nil?
121
+ includes ||= %w[lib\/action_web_service\.rb$ lib\/action_web_service\/.*\.rb$]
122
+ excludes ||= %w[lib\/action_web_service\/vendor]
123
+ Find.find(prefix) do |file_name|
124
+ next if file_name =~ /\.svn/
125
+ file_name.gsub!(/^\.\//, '')
126
+ continue = false
127
+ includes.each do |inc|
128
+ if file_name.match(/#{inc}/)
129
+ continue = true
130
+ break
131
+ end
132
+ end
133
+ next unless continue
134
+ excludes.each do |exc|
135
+ if file_name.match(/#{exc}/)
136
+ continue = false
137
+ break
138
+ end
139
+ end
140
+ next unless continue
141
+ if open_file
142
+ File.open(file_name) do |f|
143
+ yield file_name, f
144
+ end
145
+ else
146
+ yield file_name
147
+ end
148
+ end
149
+ end
150
+
151
+ desc "Count lines of the AWS source code"
152
+ task :lines do
153
+ total_lines = total_loc = 0
154
+ puts "Per File:"
155
+ each_source_file do |file_name, f|
156
+ file_lines = file_loc = 0
157
+ while line = f.gets
158
+ file_lines += 1
159
+ next if line =~ /^\s*$/
160
+ next if line =~ /^\s*#/
161
+ file_loc += 1
162
+ end
163
+ puts " #{file_name}: Lines #{file_lines}, LOC #{file_loc}"
164
+ total_lines += file_lines
165
+ total_loc += file_loc
166
+ end
167
+ puts "Total:"
168
+ puts " Lines #{total_lines}, LOC #{total_loc}"
169
+ end
170
+
171
+ desc "Publish the release files to RubyForge."
172
+ task :release => [ :package ] do
173
+ require 'rubyforge'
174
+
175
+ packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
176
+
177
+ rubyforge = RubyForge.new
178
+ rubyforge.login
179
+ rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
180
+ end
data/TODO ADDED
@@ -0,0 +1,32 @@
1
+ = Post-1.0
2
+ - Document/Literal SOAP support
3
+ - URL-based dispatching, URL identifies method
4
+
5
+ - Add :rest dispatching mode, a.l.a. Backpack API. Clean up dispatching
6
+ in general. Support vanilla XML-format as a "Rails" protocol?
7
+ XML::Simple deserialization into params?
8
+
9
+ web_service_dispatching_mode :rest
10
+
11
+ def method1(params)
12
+ end
13
+
14
+ def method2(params)
15
+ end
16
+
17
+
18
+ /ws/method1
19
+ <xml>
20
+ /ws/method2
21
+ <yaml>
22
+
23
+ - Allow locking down a controller to only accept messages for a particular
24
+ protocol. This will allow us to generate fully conformant error messages
25
+ in cases where we currently fudge it if we don't know the protocol.
26
+
27
+ - Allow AWS user to participate in typecasting, so they can centralize
28
+ workarounds for buggy input in one place
29
+
30
+ = Refactoring
31
+ - Don't have clean way to go from SOAP Class object to the xsd:NAME type
32
+ string -- NaHi possibly looking at remedying this situation
@@ -0,0 +1,50 @@
1
+ class DirectoryCategory < ActionWebService::Struct
2
+ member :fullViewableName, :string
3
+ member :specialEncoding, :string
4
+ end
5
+
6
+ class ResultElement < ActionWebService::Struct
7
+ member :summary, :string
8
+ member :URL, :string
9
+ member :snippet, :string
10
+ member :title, :string
11
+ member :cachedSize, :string
12
+ member :relatedInformationPresent, :bool
13
+ member :hostName, :string
14
+ member :directoryCategory, DirectoryCategory
15
+ member :directoryTitle, :string
16
+ end
17
+
18
+ class GoogleSearchResult < ActionWebService::Struct
19
+ member :documentFiltering, :bool
20
+ member :searchComments, :string
21
+ member :estimatedTotalResultsCount, :int
22
+ member :estimateIsExact, :bool
23
+ member :resultElements, [ResultElement]
24
+ member :searchQuery, :string
25
+ member :startIndex, :int
26
+ member :endIndex, :int
27
+ member :searchTips, :string
28
+ member :directoryCategories, [DirectoryCategory]
29
+ member :searchTime, :float
30
+ end
31
+
32
+ class GoogleSearchAPI < ActionWebService::API::Base
33
+ inflect_names false
34
+
35
+ api_method :doGetCachedPage, :returns => [:string], :expects => [{:key=>:string}, {:url=>:string}]
36
+ api_method :doGetSpellingSuggestion, :returns => [:string], :expects => [{:key=>:string}, {:phrase=>:string}]
37
+
38
+ api_method :doGoogleSearch, :returns => [GoogleSearchResult], :expects => [
39
+ {:key=>:string},
40
+ {:q=>:string},
41
+ {:start=>:int},
42
+ {:maxResults=>:int},
43
+ {:filter=>:bool},
44
+ {:restrict=>:string},
45
+ {:safeSearch=>:bool},
46
+ {:lr=>:string},
47
+ {:ie=>:string},
48
+ {:oe=>:string}
49
+ ]
50
+ end
@@ -0,0 +1,57 @@
1
+ class GoogleSearchController < ApplicationController
2
+ wsdl_service_name 'GoogleSearch'
3
+
4
+ def doGetCachedPage
5
+ "<html><body>i am a cached page. my key was %s, url was %s</body></html>" % [@params['key'], @params['url']]
6
+ end
7
+
8
+ def doSpellingSuggestion
9
+ "%s: Did you mean '%s'?" % [@params['key'], @params['phrase']]
10
+ end
11
+
12
+ def doGoogleSearch
13
+ resultElement = ResultElement.new
14
+ resultElement.summary = "ONlamp.com: Rolling with Ruby on Rails"
15
+ resultElement.URL = "http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html"
16
+ resultElement.snippet = "Curt Hibbs shows off Ruby on Rails by building a simple application that requires " +
17
+ "almost no Ruby experience. ... Rolling with Ruby on Rails. ..."
18
+ resultElement.title = "Teh Railz0r"
19
+ resultElement.cachedSize = "Almost no lines of code!"
20
+ resultElement.relatedInformationPresent = true
21
+ resultElement.hostName = "rubyonrails.com"
22
+ resultElement.directoryCategory = category("Web Development", "UTF-8")
23
+
24
+ result = GoogleSearchResult.new
25
+ result.documentFiltering = @params['filter']
26
+ result.searchComments = ""
27
+ result.estimatedTotalResultsCount = 322000
28
+ result.estimateIsExact = false
29
+ result.resultElements = [resultElement]
30
+ result.searchQuery = "http://www.google.com/search?q=ruby+on+rails"
31
+ result.startIndex = @params['start']
32
+ result.endIndex = @params['start'] + @params['maxResults']
33
+ result.searchTips = "\"on\" is a very common word and was not included in your search [details]"
34
+ result.searchTime = 0.000001
35
+
36
+ # For Mono, we have to clone objects if they're referenced by more than one place, otherwise
37
+ # the Ruby SOAP collapses them into one instance and uses references all over the
38
+ # place, confusing Mono.
39
+ #
40
+ # This has recently been fixed:
41
+ # http://bugzilla.ximian.com/show_bug.cgi?id=72265
42
+ result.directoryCategories = [
43
+ category("Web Development", "UTF-8"),
44
+ category("Programming", "US-ASCII"),
45
+ ]
46
+
47
+ result
48
+ end
49
+
50
+ private
51
+ def category(name, encoding)
52
+ cat = DirectoryCategory.new
53
+ cat.fullViewableName = name.dup
54
+ cat.specialEncoding = encoding.dup
55
+ cat
56
+ end
57
+ end
@@ -0,0 +1,108 @@
1
+ class DirectoryCategory < ActionWebService::Struct
2
+ member :fullViewableName, :string
3
+ member :specialEncoding, :string
4
+ end
5
+
6
+ class ResultElement < ActionWebService::Struct
7
+ member :summary, :string
8
+ member :URL, :string
9
+ member :snippet, :string
10
+ member :title, :string
11
+ member :cachedSize, :string
12
+ member :relatedInformationPresent, :bool
13
+ member :hostName, :string
14
+ member :directoryCategory, DirectoryCategory
15
+ member :directoryTitle, :string
16
+ end
17
+
18
+ class GoogleSearchResult < ActionWebService::Struct
19
+ member :documentFiltering, :bool
20
+ member :searchComments, :string
21
+ member :estimatedTotalResultsCount, :int
22
+ member :estimateIsExact, :bool
23
+ member :resultElements, [ResultElement]
24
+ member :searchQuery, :string
25
+ member :startIndex, :int
26
+ member :endIndex, :int
27
+ member :searchTips, :string
28
+ member :directoryCategories, [DirectoryCategory]
29
+ member :searchTime, :float
30
+ end
31
+
32
+ class GoogleSearchAPI < ActionWebService::API::Base
33
+ inflect_names false
34
+
35
+ api_method :doGetCachedPage, :returns => [:string], :expects => [{:key=>:string}, {:url=>:string}]
36
+ api_method :doGetSpellingSuggestion, :returns => [:string], :expects => [{:key=>:string}, {:phrase=>:string}]
37
+
38
+ api_method :doGoogleSearch, :returns => [GoogleSearchResult], :expects => [
39
+ {:key=>:string},
40
+ {:q=>:string},
41
+ {:start=>:int},
42
+ {:maxResults=>:int},
43
+ {:filter=>:bool},
44
+ {:restrict=>:string},
45
+ {:safeSearch=>:bool},
46
+ {:lr=>:string},
47
+ {:ie=>:string},
48
+ {:oe=>:string}
49
+ ]
50
+ end
51
+
52
+ class GoogleSearchService < ActionWebService::Base
53
+ web_service_api GoogleSearchAPI
54
+
55
+ def doGetCachedPage(key, url)
56
+ "<html><body>i am a cached page</body></html>"
57
+ end
58
+
59
+ def doSpellingSuggestion(key, phrase)
60
+ "Did you mean 'teh'?"
61
+ end
62
+
63
+ def doGoogleSearch(key, q, start, maxResults, filter, restrict, safeSearch, lr, ie, oe)
64
+ resultElement = ResultElement.new
65
+ resultElement.summary = "ONlamp.com: Rolling with Ruby on Rails"
66
+ resultElement.URL = "http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html"
67
+ resultElement.snippet = "Curt Hibbs shows off Ruby on Rails by building a simple application that requires " +
68
+ "almost no Ruby experience. ... Rolling with Ruby on Rails. ..."
69
+ resultElement.title = "Teh Railz0r"
70
+ resultElement.cachedSize = "Almost no lines of code!"
71
+ resultElement.relatedInformationPresent = true
72
+ resultElement.hostName = "rubyonrails.com"
73
+ resultElement.directoryCategory = category("Web Development", "UTF-8")
74
+
75
+ result = GoogleSearchResult.new
76
+ result.documentFiltering = filter
77
+ result.searchComments = ""
78
+ result.estimatedTotalResultsCount = 322000
79
+ result.estimateIsExact = false
80
+ result.resultElements = [resultElement]
81
+ result.searchQuery = "http://www.google.com/search?q=ruby+on+rails"
82
+ result.startIndex = start
83
+ result.endIndex = start + maxResults
84
+ result.searchTips = "\"on\" is a very common word and was not included in your search [details]"
85
+ result.searchTime = 0.000001
86
+
87
+ # For Mono, we have to clone objects if they're referenced by more than one place, otherwise
88
+ # the Ruby SOAP collapses them into one instance and uses references all over the
89
+ # place, confusing Mono.
90
+ #
91
+ # This has recently been fixed:
92
+ # http://bugzilla.ximian.com/show_bug.cgi?id=72265
93
+ result.directoryCategories = [
94
+ category("Web Development", "UTF-8"),
95
+ category("Programming", "US-ASCII"),
96
+ ]
97
+
98
+ result
99
+ end
100
+
101
+ private
102
+ def category(name, encoding)
103
+ cat = DirectoryCategory.new
104
+ cat.fullViewableName = name.dup
105
+ cat.specialEncoding = encoding.dup
106
+ cat
107
+ end
108
+ end
@@ -0,0 +1,7 @@
1
+ require 'google_search_service'
2
+
3
+ class SearchController < ApplicationController
4
+ wsdl_service_name 'GoogleSearch'
5
+ web_service_dispatching_mode :delegated
6
+ web_service :beta3, GoogleSearchService.new
7
+ end
@@ -0,0 +1,50 @@
1
+ class DirectoryCategory < ActionWebService::Struct
2
+ member :fullViewableName, :string
3
+ member :specialEncoding, :string
4
+ end
5
+
6
+ class ResultElement < ActionWebService::Struct
7
+ member :summary, :string
8
+ member :URL, :string
9
+ member :snippet, :string
10
+ member :title, :string
11
+ member :cachedSize, :string
12
+ member :relatedInformationPresent, :bool
13
+ member :hostName, :string
14
+ member :directoryCategory, DirectoryCategory
15
+ member :directoryTitle, :string
16
+ end
17
+
18
+ class GoogleSearchResult < ActionWebService::Struct
19
+ member :documentFiltering, :bool
20
+ member :searchComments, :string
21
+ member :estimatedTotalResultsCount, :int
22
+ member :estimateIsExact, :bool
23
+ member :resultElements, [ResultElement]
24
+ member :searchQuery, :string
25
+ member :startIndex, :int
26
+ member :endIndex, :int
27
+ member :searchTips, :string
28
+ member :directoryCategories, [DirectoryCategory]
29
+ member :searchTime, :float
30
+ end
31
+
32
+ class GoogleSearchAPI < ActionWebService::API::Base
33
+ inflect_names false
34
+
35
+ api_method :doGetCachedPage, :returns => [:string], :expects => [{:key=>:string}, {:url=>:string}]
36
+ api_method :doGetSpellingSuggestion, :returns => [:string], :expects => [{:key=>:string}, {:phrase=>:string}]
37
+
38
+ api_method :doGoogleSearch, :returns => [GoogleSearchResult], :expects => [
39
+ {:key=>:string},
40
+ {:q=>:string},
41
+ {:start=>:int},
42
+ {:maxResults=>:int},
43
+ {:filter=>:bool},
44
+ {:restrict=>:string},
45
+ {:safeSearch=>:bool},
46
+ {:lr=>:string},
47
+ {:ie=>:string},
48
+ {:oe=>:string}
49
+ ]
50
+ end