reidiculous-actionwebservice 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +320 -0
- data/MIT-LICENSE +21 -0
- data/README +381 -0
- data/Rakefile +180 -0
- data/TODO +32 -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/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.rb +71 -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 +149 -0
- data/lib/action_web_service/client.rb +3 -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/container.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/dispatcher.rb +2 -0
- data/lib/action_web_service/dispatcher/abstract.rb +207 -0
- data/lib/action_web_service/dispatcher/action_controller_dispatcher.rb +379 -0
- data/lib/action_web_service/invocation.rb +202 -0
- data/lib/action_web_service/protocol.rb +4 -0
- data/lib/action_web_service/protocol/abstract.rb +115 -0
- data/lib/action_web_service/protocol/discovery.rb +37 -0
- data/lib/action_web_service/protocol/soap_protocol.rb +176 -0
- data/lib/action_web_service/protocol/soap_protocol/marshaler.rb +242 -0
- data/lib/action_web_service/protocol/xmlrpc_protocol.rb +122 -0
- data/lib/action_web_service/scaffolding.rb +281 -0
- data/lib/action_web_service/soap/attachment.rb +107 -0
- data/lib/action_web_service/soap/baseData.rb +942 -0
- data/lib/action_web_service/soap/element.rb +258 -0
- data/lib/action_web_service/soap/encodingstyle/aspDotNetHandler.rb +213 -0
- data/lib/action_web_service/soap/encodingstyle/handler.rb +100 -0
- data/lib/action_web_service/soap/encodingstyle/literalHandler.rb +226 -0
- data/lib/action_web_service/soap/encodingstyle/soapHandler.rb +582 -0
- data/lib/action_web_service/soap/generator.rb +268 -0
- data/lib/action_web_service/soap/header/handler.rb +57 -0
- data/lib/action_web_service/soap/header/handlerset.rb +70 -0
- data/lib/action_web_service/soap/header/simplehandler.rb +44 -0
- data/lib/action_web_service/soap/httpconfigloader.rb +119 -0
- data/lib/action_web_service/soap/mapping.rb +10 -0
- data/lib/action_web_service/soap/mapping/factory.rb +355 -0
- data/lib/action_web_service/soap/mapping/mapping.rb +381 -0
- data/lib/action_web_service/soap/mapping/registry.rb +541 -0
- data/lib/action_web_service/soap/mapping/rubytypeFactory.rb +475 -0
- data/lib/action_web_service/soap/mapping/typeMap.rb +50 -0
- data/lib/action_web_service/soap/mapping/wsdlencodedregistry.rb +280 -0
- data/lib/action_web_service/soap/mapping/wsdlliteralregistry.rb +418 -0
- data/lib/action_web_service/soap/marshal.rb +59 -0
- data/lib/action_web_service/soap/mimemessage.rb +240 -0
- data/lib/action_web_service/soap/netHttpClient.rb +190 -0
- data/lib/action_web_service/soap/parser.rb +251 -0
- data/lib/action_web_service/soap/processor.rb +66 -0
- data/lib/action_web_service/soap/property.rb +333 -0
- data/lib/action_web_service/soap/rpc/cgistub.rb +206 -0
- data/lib/action_web_service/soap/rpc/driver.rb +254 -0
- data/lib/action_web_service/soap/rpc/element.rb +325 -0
- data/lib/action_web_service/soap/rpc/httpserver.rb +129 -0
- data/lib/action_web_service/soap/rpc/proxy.rb +497 -0
- data/lib/action_web_service/soap/rpc/router.rb +594 -0
- data/lib/action_web_service/soap/rpc/rpc.rb +25 -0
- data/lib/action_web_service/soap/rpc/soaplet.rb +162 -0
- data/lib/action_web_service/soap/rpc/standaloneServer.rb +43 -0
- data/lib/action_web_service/soap/soap.rb +140 -0
- data/lib/action_web_service/soap/streamHandler.rb +229 -0
- data/lib/action_web_service/soap/wsdlDriver.rb +575 -0
- data/lib/action_web_service/struct.rb +64 -0
- data/lib/action_web_service/support/class_inheritable_options.rb +28 -0
- data/lib/action_web_service/support/signature_types.rb +227 -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/wsdl/binding.rb +65 -0
- data/lib/action_web_service/wsdl/data.rb +64 -0
- data/lib/action_web_service/wsdl/definitions.rb +250 -0
- data/lib/action_web_service/wsdl/documentation.rb +32 -0
- data/lib/action_web_service/wsdl/import.rb +80 -0
- data/lib/action_web_service/wsdl/importer.rb +38 -0
- data/lib/action_web_service/wsdl/info.rb +39 -0
- data/lib/action_web_service/wsdl/message.rb +54 -0
- data/lib/action_web_service/wsdl/operation.rb +130 -0
- data/lib/action_web_service/wsdl/operationBinding.rb +108 -0
- data/lib/action_web_service/wsdl/param.rb +85 -0
- data/lib/action_web_service/wsdl/parser.rb +163 -0
- data/lib/action_web_service/wsdl/part.rb +52 -0
- data/lib/action_web_service/wsdl/port.rb +84 -0
- data/lib/action_web_service/wsdl/portType.rb +73 -0
- data/lib/action_web_service/wsdl/service.rb +61 -0
- data/lib/action_web_service/wsdl/soap/address.rb +40 -0
- data/lib/action_web_service/wsdl/soap/binding.rb +49 -0
- data/lib/action_web_service/wsdl/soap/body.rb +56 -0
- data/lib/action_web_service/wsdl/soap/cgiStubCreator.rb +76 -0
- data/lib/action_web_service/wsdl/soap/classDefCreator.rb +314 -0
- data/lib/action_web_service/wsdl/soap/classDefCreatorSupport.rb +126 -0
- data/lib/action_web_service/wsdl/soap/clientSkeltonCreator.rb +78 -0
- data/lib/action_web_service/wsdl/soap/complexType.rb +161 -0
- data/lib/action_web_service/wsdl/soap/data.rb +42 -0
- data/lib/action_web_service/wsdl/soap/definitions.rb +149 -0
- data/lib/action_web_service/wsdl/soap/driverCreator.rb +95 -0
- data/lib/action_web_service/wsdl/soap/element.rb +28 -0
- data/lib/action_web_service/wsdl/soap/fault.rb +56 -0
- data/lib/action_web_service/wsdl/soap/header.rb +86 -0
- data/lib/action_web_service/wsdl/soap/headerfault.rb +56 -0
- data/lib/action_web_service/wsdl/soap/mappingRegistryCreator.rb +92 -0
- data/lib/action_web_service/wsdl/soap/methodDefCreator.rb +228 -0
- data/lib/action_web_service/wsdl/soap/operation.rb +122 -0
- data/lib/action_web_service/wsdl/soap/servantSkeltonCreator.rb +67 -0
- data/lib/action_web_service/wsdl/soap/standaloneServerStubCreator.rb +85 -0
- data/lib/action_web_service/wsdl/soap/wsdl2ruby.rb +176 -0
- data/lib/action_web_service/wsdl/types.rb +43 -0
- data/lib/action_web_service/wsdl/wsdl.rb +23 -0
- data/lib/action_web_service/wsdl/xmlSchema/all.rb +69 -0
- data/lib/action_web_service/wsdl/xmlSchema/annotation.rb +34 -0
- data/lib/action_web_service/wsdl/xmlSchema/any.rb +56 -0
- data/lib/action_web_service/wsdl/xmlSchema/attribute.rb +127 -0
- data/lib/action_web_service/wsdl/xmlSchema/choice.rb +69 -0
- data/lib/action_web_service/wsdl/xmlSchema/complexContent.rb +92 -0
- data/lib/action_web_service/wsdl/xmlSchema/complexType.rb +139 -0
- data/lib/action_web_service/wsdl/xmlSchema/content.rb +96 -0
- data/lib/action_web_service/wsdl/xmlSchema/data.rb +80 -0
- data/lib/action_web_service/wsdl/xmlSchema/element.rb +154 -0
- data/lib/action_web_service/wsdl/xmlSchema/enumeration.rb +36 -0
- data/lib/action_web_service/wsdl/xmlSchema/import.rb +65 -0
- data/lib/action_web_service/wsdl/xmlSchema/importer.rb +87 -0
- data/lib/action_web_service/wsdl/xmlSchema/include.rb +54 -0
- data/lib/action_web_service/wsdl/xmlSchema/length.rb +35 -0
- data/lib/action_web_service/wsdl/xmlSchema/parser.rb +166 -0
- data/lib/action_web_service/wsdl/xmlSchema/pattern.rb +36 -0
- data/lib/action_web_service/wsdl/xmlSchema/schema.rb +143 -0
- data/lib/action_web_service/wsdl/xmlSchema/sequence.rb +69 -0
- data/lib/action_web_service/wsdl/xmlSchema/simpleContent.rb +65 -0
- data/lib/action_web_service/wsdl/xmlSchema/simpleExtension.rb +54 -0
- data/lib/action_web_service/wsdl/xmlSchema/simpleRestriction.rb +73 -0
- data/lib/action_web_service/wsdl/xmlSchema/simpleType.rb +73 -0
- data/lib/action_web_service/wsdl/xmlSchema/unique.rb +34 -0
- data/lib/action_web_service/wsdl/xmlSchema/xsd2ruby.rb +107 -0
- data/lib/action_web_service/xsd/charset.rb +187 -0
- data/lib/action_web_service/xsd/codegen.rb +12 -0
- data/lib/action_web_service/xsd/codegen/classdef.rb +203 -0
- data/lib/action_web_service/xsd/codegen/commentdef.rb +34 -0
- data/lib/action_web_service/xsd/codegen/gensupport.rb +166 -0
- data/lib/action_web_service/xsd/codegen/methoddef.rb +63 -0
- data/lib/action_web_service/xsd/codegen/moduledef.rb +191 -0
- data/lib/action_web_service/xsd/datatypes.rb +1269 -0
- data/lib/action_web_service/xsd/datatypes1999.rb +20 -0
- data/lib/action_web_service/xsd/iconvcharset.rb +33 -0
- data/lib/action_web_service/xsd/mapping.rb +42 -0
- data/lib/action_web_service/xsd/namedelements.rb +95 -0
- data/lib/action_web_service/xsd/ns.rb +140 -0
- data/lib/action_web_service/xsd/qname.rb +78 -0
- data/lib/action_web_service/xsd/xmlparser.rb +61 -0
- data/lib/action_web_service/xsd/xmlparser/parser.rb +96 -0
- data/lib/action_web_service/xsd/xmlparser/rexmlparser.rb +54 -0
- data/lib/action_web_service/xsd/xmlparser/xmlparser.rb +50 -0
- data/lib/action_web_service/xsd/xmlparser/xmlscanner.rb +147 -0
- data/lib/actionwebservice.rb +1 -0
- data/setup.rb +1379 -0
- data/test/abstract_client.rb +183 -0
- data/test/abstract_dispatcher.rb +548 -0
- data/test/abstract_unit.rb +45 -0
- data/test/api_test.rb +103 -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 +153 -0
- data/test/container_test.rb +73 -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 +185 -0
- data/test/run +6 -0
- data/test/scaffolded_controller_test.rb +146 -0
- data/test/struct_test.rb +52 -0
- data/test/test_invoke_test.rb +112 -0
- metadata +281 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
class SearchController < ApplicationController
|
2
|
+
web_service_api :google_search
|
3
|
+
wsdl_service_name 'GoogleSearch'
|
4
|
+
|
5
|
+
def doGetCachedPage
|
6
|
+
"<html><body>i am a cached page. my key was %s, url was %s</body></html>" % [@params['key'], @params['url']]
|
7
|
+
end
|
8
|
+
|
9
|
+
def doSpellingSuggestion
|
10
|
+
"%s: Did you mean '%s'?" % [@params['key'], @params['phrase']]
|
11
|
+
end
|
12
|
+
|
13
|
+
def doGoogleSearch
|
14
|
+
resultElement = ResultElement.new
|
15
|
+
resultElement.summary = "ONlamp.com: Rolling with Ruby on Rails"
|
16
|
+
resultElement.URL = "http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html"
|
17
|
+
resultElement.snippet = "Curt Hibbs shows off Ruby on Rails by building a simple application that requires " +
|
18
|
+
"almost no Ruby experience. ... Rolling with Ruby on Rails. ..."
|
19
|
+
resultElement.title = "Teh Railz0r"
|
20
|
+
resultElement.cachedSize = "Almost no lines of code!"
|
21
|
+
resultElement.relatedInformationPresent = true
|
22
|
+
resultElement.hostName = "rubyonrails.com"
|
23
|
+
resultElement.directoryCategory = category("Web Development", "UTF-8")
|
24
|
+
|
25
|
+
result = GoogleSearchResult.new
|
26
|
+
result.documentFiltering = @params['filter']
|
27
|
+
result.searchComments = ""
|
28
|
+
result.estimatedTotalResultsCount = 322000
|
29
|
+
result.estimateIsExact = false
|
30
|
+
result.resultElements = [resultElement]
|
31
|
+
result.searchQuery = "http://www.google.com/search?q=ruby+on+rails"
|
32
|
+
result.startIndex = @params['start']
|
33
|
+
result.endIndex = @params['start'] + @params['maxResults']
|
34
|
+
result.searchTips = "\"on\" is a very common word and was not included in your search [details]"
|
35
|
+
result.searchTime = 0.000001
|
36
|
+
|
37
|
+
# For Mono, we have to clone objects if they're referenced by more than one place, otherwise
|
38
|
+
# the Ruby SOAP collapses them into one instance and uses references all over the
|
39
|
+
# place, confusing Mono.
|
40
|
+
#
|
41
|
+
# This has recently been fixed:
|
42
|
+
# http://bugzilla.ximian.com/show_bug.cgi?id=72265
|
43
|
+
result.directoryCategories = [
|
44
|
+
category("Web Development", "UTF-8"),
|
45
|
+
category("Programming", "US-ASCII"),
|
46
|
+
]
|
47
|
+
|
48
|
+
result
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
def category(name, encoding)
|
53
|
+
cat = DirectoryCategory.new
|
54
|
+
cat.fullViewableName = name.dup
|
55
|
+
cat.specialEncoding = encoding.dup
|
56
|
+
cat
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#
|
2
|
+
# see the blogger API spec at http://www.blogger.com/developers/api/1_docs/
|
3
|
+
# note that the method signatures are subtly different to metaWeblog, they
|
4
|
+
# are not identical. take care to ensure you handle the different semantics
|
5
|
+
# properly if you want to support blogger API too, to get maximum compatibility.
|
6
|
+
#
|
7
|
+
|
8
|
+
module Blog
|
9
|
+
class Blog < ActionWebService::Struct
|
10
|
+
member :url, :string
|
11
|
+
member :blogid, :string
|
12
|
+
member :blogName, :string
|
13
|
+
end
|
14
|
+
|
15
|
+
class User < ActionWebService::Struct
|
16
|
+
member :nickname, :string
|
17
|
+
member :userid, :string
|
18
|
+
member :url, :string
|
19
|
+
member :email, :string
|
20
|
+
member :lastname, :string
|
21
|
+
member :firstname, :string
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# blogger
|
27
|
+
#
|
28
|
+
class BloggerAPI < ActionWebService::API::Base
|
29
|
+
inflect_names false
|
30
|
+
|
31
|
+
api_method :newPost, :returns => [:string], :expects => [
|
32
|
+
{:appkey=>:string},
|
33
|
+
{:blogid=>:string},
|
34
|
+
{:username=>:string},
|
35
|
+
{:password=>:string},
|
36
|
+
{:content=>:string},
|
37
|
+
{:publish=>:bool}
|
38
|
+
]
|
39
|
+
|
40
|
+
api_method :editPost, :returns => [:bool], :expects => [
|
41
|
+
{:appkey=>:string},
|
42
|
+
{:postid=>:string},
|
43
|
+
{:username=>:string},
|
44
|
+
{:password=>:string},
|
45
|
+
{:content=>:string},
|
46
|
+
{:publish=>:bool}
|
47
|
+
]
|
48
|
+
|
49
|
+
api_method :getUsersBlogs, :returns => [[Blog::Blog]], :expects => [
|
50
|
+
{:appkey=>:string},
|
51
|
+
{:username=>:string},
|
52
|
+
{:password=>:string}
|
53
|
+
]
|
54
|
+
|
55
|
+
api_method :getUserInfo, :returns => [Blog::User], :expects => [
|
56
|
+
{:appkey=>:string},
|
57
|
+
{:username=>:string},
|
58
|
+
{:password=>:string}
|
59
|
+
]
|
60
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'blogger_api'
|
2
|
+
|
3
|
+
class BloggerService < ActionWebService::Base
|
4
|
+
web_service_api BloggerAPI
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@postid = 0
|
8
|
+
end
|
9
|
+
|
10
|
+
def newPost(key, id, user, pw, content, publish)
|
11
|
+
$stderr.puts "id=#{id} user=#{user} pw=#{pw}, content=#{content.inspect} [#{publish}]"
|
12
|
+
(@postid += 1).to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
def editPost(key, post_id, user, pw, content, publish)
|
16
|
+
$stderr.puts "id=#{post_id} user=#{user} pw=#{pw} content=#{content.inspect} [#{publish}]"
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
20
|
+
def getUsersBlogs(key, user, pw)
|
21
|
+
$stderr.puts "getting blogs for #{user}"
|
22
|
+
blog = Blog::Blog.new(
|
23
|
+
:url =>'http://blog',
|
24
|
+
:blogid => 'myblog',
|
25
|
+
:blogName => 'My Blog'
|
26
|
+
)
|
27
|
+
[blog]
|
28
|
+
end
|
29
|
+
|
30
|
+
def getUserInfo(key, user, pw)
|
31
|
+
$stderr.puts "getting user info for #{user}"
|
32
|
+
Blog::User.new(:nickname => 'user', :email => 'user@test.com')
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#
|
2
|
+
# here lie structures, cousins of those on http://www.xmlrpc.com/metaWeblog
|
3
|
+
# but they don't necessarily the real world reflect
|
4
|
+
# so if you do, find that your client complains:
|
5
|
+
# please tell, of problems you suffered through
|
6
|
+
#
|
7
|
+
|
8
|
+
module Blog
|
9
|
+
class Post < ActionWebService::Struct
|
10
|
+
member :title, :string
|
11
|
+
member :link, :string
|
12
|
+
member :description, :string
|
13
|
+
member :author, :string
|
14
|
+
member :category, :string
|
15
|
+
member :comments, :string
|
16
|
+
member :guid, :string
|
17
|
+
member :pubDate, :string
|
18
|
+
end
|
19
|
+
|
20
|
+
class Category < ActionWebService::Struct
|
21
|
+
member :description, :string
|
22
|
+
member :htmlUrl, :string
|
23
|
+
member :rssUrl, :string
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
#
|
28
|
+
# metaWeblog
|
29
|
+
#
|
30
|
+
class MetaWeblogAPI < ActionWebService::API::Base
|
31
|
+
inflect_names false
|
32
|
+
|
33
|
+
api_method :newPost, :returns => [:string], :expects => [
|
34
|
+
{:blogid=>:string},
|
35
|
+
{:username=>:string},
|
36
|
+
{:password=>:string},
|
37
|
+
{:struct=>Blog::Post},
|
38
|
+
{:publish=>:bool}
|
39
|
+
]
|
40
|
+
|
41
|
+
api_method :editPost, :returns => [:bool], :expects => [
|
42
|
+
{:postid=>:string},
|
43
|
+
{:username=>:string},
|
44
|
+
{:password=>:string},
|
45
|
+
{:struct=>Blog::Post},
|
46
|
+
{:publish=>:bool},
|
47
|
+
]
|
48
|
+
|
49
|
+
api_method :getPost, :returns => [Blog::Post], :expects => [
|
50
|
+
{:postid=>:string},
|
51
|
+
{:username=>:string},
|
52
|
+
{:password=>:string},
|
53
|
+
]
|
54
|
+
|
55
|
+
api_method :getCategories, :returns => [[Blog::Category]], :expects => [
|
56
|
+
{:blogid=>:string},
|
57
|
+
{:username=>:string},
|
58
|
+
{:password=>:string},
|
59
|
+
]
|
60
|
+
|
61
|
+
api_method :getRecentPosts, :returns => [[Blog::Post]], :expects => [
|
62
|
+
{:blogid=>:string},
|
63
|
+
{:username=>:string},
|
64
|
+
{:password=>:string},
|
65
|
+
{:numberOfPosts=>:int},
|
66
|
+
]
|
67
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'meta_weblog_api'
|
2
|
+
|
3
|
+
class MetaWeblogService < ActionWebService::Base
|
4
|
+
web_service_api MetaWeblogAPI
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@postid = 0
|
8
|
+
end
|
9
|
+
|
10
|
+
def newPost(id, user, pw, struct, publish)
|
11
|
+
$stderr.puts "id=#{id} user=#{user} pw=#{pw}, struct=#{struct.inspect} [#{publish}]"
|
12
|
+
(@postid += 1).to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
def editPost(post_id, user, pw, struct, publish)
|
16
|
+
$stderr.puts "id=#{post_id} user=#{user} pw=#{pw} struct=#{struct.inspect} [#{publish}]"
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
20
|
+
def getPost(post_id, user, pw)
|
21
|
+
$stderr.puts "get post #{post_id}"
|
22
|
+
Blog::Post.new(:title => 'hello world', :description => 'first post!')
|
23
|
+
end
|
24
|
+
|
25
|
+
def getCategories(id, user, pw)
|
26
|
+
$stderr.puts "categories for #{user}"
|
27
|
+
cat = Blog::Category.new(
|
28
|
+
:description => 'Tech',
|
29
|
+
:htmlUrl => 'http://blog/tech',
|
30
|
+
:rssUrl => 'http://blog/tech.rss')
|
31
|
+
[cat]
|
32
|
+
end
|
33
|
+
|
34
|
+
def getRecentPosts(id, user, pw, num)
|
35
|
+
$stderr.puts "recent #{num} posts for #{user} on blog #{id}"
|
36
|
+
post1 = Blog::Post.new(
|
37
|
+
:title => 'first post!',
|
38
|
+
:link => 'http://blog.xeraph.org/testOne.html',
|
39
|
+
:description => 'this is the first post'
|
40
|
+
)
|
41
|
+
post2 = Blog::Post.new(
|
42
|
+
:title => 'second post!',
|
43
|
+
:link => 'http://blog.xeraph.org/testTwo.html',
|
44
|
+
:description => 'this is the second post'
|
45
|
+
)
|
46
|
+
[post1, post2]
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#
|
2
|
+
# example controller implementing both blogger and metaWeblog APIs
|
3
|
+
# in a way that should be compatible with clients supporting both/either.
|
4
|
+
#
|
5
|
+
# test by pointing your client at http://URL/xmlrpc/api
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'meta_weblog_service'
|
9
|
+
require 'blogger_service'
|
10
|
+
|
11
|
+
class XmlrpcController < ApplicationController
|
12
|
+
web_service_dispatching_mode :layered
|
13
|
+
|
14
|
+
web_service :metaWeblog, MetaWeblogService.new
|
15
|
+
web_service :blogger, BloggerService.new
|
16
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
Description:
|
2
|
+
The web service generator creates the controller and API definition for
|
3
|
+
a web service.
|
4
|
+
|
5
|
+
The generator takes a web service name and a list of API methods as arguments.
|
6
|
+
The web service name may be given in CamelCase or under_score and should
|
7
|
+
contain no extra suffixes. To create a web service within a
|
8
|
+
module, specify the web service name as 'module/webservice'.
|
9
|
+
|
10
|
+
The generator creates a controller class in app/controllers, an API definition
|
11
|
+
in app/apis, and a functional test suite in test/functional.
|
12
|
+
|
13
|
+
Example:
|
14
|
+
./script/generate web_service User add edit list remove
|
15
|
+
|
16
|
+
User web service.
|
17
|
+
Controller: app/controllers/user_controller.rb
|
18
|
+
API: app/apis/user_api.rb
|
19
|
+
Test: test/functional/user_api_test.rb
|
20
|
+
|
21
|
+
Modules Example:
|
22
|
+
./script/generate web_service 'api/registration' register renew
|
23
|
+
|
24
|
+
Registration web service.
|
25
|
+
Controller: app/controllers/api/registration_controller.rb
|
26
|
+
API: app/apis/api/registration_api.rb
|
27
|
+
Test: test/functional/api/registration_api_test.rb
|
28
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../test_helper'
|
2
|
+
require '<%= file_path %>_controller'
|
3
|
+
|
4
|
+
class <%= class_name %>Controller; def rescue_action(e) raise e end; end
|
5
|
+
|
6
|
+
class <%= class_name %>ControllerApiTest < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@controller = <%= class_name %>Controller.new
|
9
|
+
@request = ActionController::TestRequest.new
|
10
|
+
@response = ActionController::TestResponse.new
|
11
|
+
end
|
12
|
+
<% for method_name in args -%>
|
13
|
+
|
14
|
+
def test_<%= method_name %>
|
15
|
+
result = invoke :<%= method_name %>
|
16
|
+
assert_equal nil, result
|
17
|
+
end
|
18
|
+
<% end -%>
|
19
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class WebServiceGenerator < Rails::Generator::NamedBase
|
2
|
+
def manifest
|
3
|
+
record do |m|
|
4
|
+
# Check for class naming collisions.
|
5
|
+
m.class_collisions class_path, "#{class_name}Api", "#{class_name}Controller", "#{class_name}ApiTest"
|
6
|
+
|
7
|
+
# API and test directories.
|
8
|
+
m.directory File.join('app/services', class_path)
|
9
|
+
m.directory File.join('app/controllers', class_path)
|
10
|
+
m.directory File.join('test/functional', class_path)
|
11
|
+
|
12
|
+
# API definition, controller, and functional test.
|
13
|
+
m.template 'api_definition.rb',
|
14
|
+
File.join('app/services',
|
15
|
+
class_path,
|
16
|
+
"#{file_name}_api.rb")
|
17
|
+
|
18
|
+
m.template 'controller.rb',
|
19
|
+
File.join('app/controllers',
|
20
|
+
class_path,
|
21
|
+
"#{file_name}_controller.rb")
|
22
|
+
|
23
|
+
m.template 'functional_test.rb',
|
24
|
+
File.join('test/functional',
|
25
|
+
class_path,
|
26
|
+
"#{file_name}_api_test.rb")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (C) 2005 Leon Breedt
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
begin
|
25
|
+
require 'activesupport'
|
26
|
+
require 'actioncontroller'
|
27
|
+
require 'activerecord'
|
28
|
+
require 'activesupport'
|
29
|
+
require 'actionpack'
|
30
|
+
require 'active_support/core_ext/class/inheritable_attributes'
|
31
|
+
require 'action_dispatch/routing'
|
32
|
+
rescue LoadError
|
33
|
+
require 'rubygems'
|
34
|
+
gem 'activesupport', '3.0.3'
|
35
|
+
gem 'actionpack', '3.0.3'
|
36
|
+
gem 'activerecord', '3.0.3'
|
37
|
+
gem 'activesupport', '3.0.3'
|
38
|
+
end
|
39
|
+
|
40
|
+
$:.unshift(File.dirname(__FILE__) + "/action_web_service/vendor/")
|
41
|
+
|
42
|
+
require 'action_web_service/support/class_inheritable_options'
|
43
|
+
require 'action_web_service/support/signature_types'
|
44
|
+
require 'action_web_service/base'
|
45
|
+
require 'action_web_service/client'
|
46
|
+
require 'action_web_service/invocation'
|
47
|
+
require 'action_web_service/api'
|
48
|
+
require 'action_web_service/casting'
|
49
|
+
require 'action_web_service/struct'
|
50
|
+
require 'action_web_service/container'
|
51
|
+
require 'action_web_service/protocol'
|
52
|
+
require 'action_web_service/dispatcher'
|
53
|
+
require 'action_web_service/scaffolding'
|
54
|
+
|
55
|
+
ActionWebService::Base.class_eval do
|
56
|
+
include ActionWebService::Container::Direct
|
57
|
+
include ActionWebService::Invocation
|
58
|
+
end
|
59
|
+
|
60
|
+
ActionController::Base.class_eval do
|
61
|
+
include ActionWebService::Protocol::Discovery
|
62
|
+
include ActionWebService::Protocol::Soap
|
63
|
+
include ActionWebService::Protocol::XmlRpc
|
64
|
+
include ActionWebService::Container::Direct
|
65
|
+
include ActionWebService::Container::Delegated
|
66
|
+
include ActionWebService::Container::ActionController
|
67
|
+
include ActionWebService::Invocation
|
68
|
+
include ActionWebService::Dispatcher
|
69
|
+
include ActionWebService::Dispatcher::ActionController
|
70
|
+
include ActionWebService::Scaffolding
|
71
|
+
end
|