actionwebservice 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,16 @@
1
+ *0.6.1* (22th March, 2005)
2
+
3
+ * Fix that method response QNames mismatched with that declared in the WSDL, makes SOAP::WSDLDriverFactory work against AWS again
4
+
5
+ * Fix that @request.env was being modified, instead, dup the value gotten from env
6
+
7
+ * Fix XML-RPC example to use :layered mode, so it works again
8
+
9
+ * Support casting '0' or 0 into false, and '1' or 1 into true, when expecting a boolean value
10
+
11
+ * Fix that SOAP fault response fault code values were not QName's #804
12
+
13
+
1
14
  *0.6.0* (7th March, 2005)
2
15
 
3
16
  * Add action_controller/test_invoke, used for integrating AWS with the Rails testing infrastructure
@@ -18,6 +31,7 @@
18
31
 
19
32
  * Replace '::' with '..' in fully qualified type names for marshaling and WSDL. This improves interoperability with .NET, and closes #676.
20
33
 
34
+
21
35
  *0.5.0* (24th February, 2005)
22
36
 
23
37
  * lib/action_service/dispatcher*: replace "router" fragments with
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ require 'fileutils'
9
9
 
10
10
  PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
11
11
  PKG_NAME = 'actionwebservice'
12
- PKG_VERSION = '0.6.0' + PKG_BUILD
12
+ PKG_VERSION = '0.6.1' + PKG_BUILD
13
13
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
14
14
  PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
15
15
 
@@ -56,9 +56,9 @@ spec = Gem::Specification.new do |s|
56
56
  s.rubyforge_project = "aws"
57
57
  s.homepage = "http://www.rubyonrails.org"
58
58
 
59
- s.add_dependency('actionpack', '>= 1.5.1' + PKG_BUILD)
60
- s.add_dependency('activerecord', '>= 1.8.0' + PKG_BUILD)
61
- s.add_dependency('activesupport', '>= 1.0.1' + PKG_BUILD)
59
+ s.add_dependency('actionpack', '= 1.6.0' + PKG_BUILD)
60
+ s.add_dependency('activerecord', '= 1.9.0' + PKG_BUILD)
61
+ s.add_dependency('activesupport', '= 1.0.2' + PKG_BUILD)
62
62
 
63
63
  s.has_rdoc = true
64
64
  s.requirements << 'none'
data/TODO CHANGED
@@ -1,7 +1,6 @@
1
1
  = 0.7.0
2
- - WS Test Integration
3
- - WS Scaffolding
4
- - WS Generators
2
+ - WS Dynamic Scaffolding
3
+ - WS Scaffolding Generators
5
4
 
6
5
  = 0.8.0
7
6
  - Consumption of WSDL services
@@ -1,16 +1,17 @@
1
1
  = metaWeblog example
2
2
 
3
-
4
3
  This example shows how one might begin to go about adding metaWeblog
5
4
  (http://www.xmlrpc.com/metaWeblogApi) API support to a Rails-based
6
5
  blogging application.
7
6
 
7
+ The example APIs are more verbose than you may want to make them, for documentation
8
+ reasons.
8
9
 
9
10
  = Running
10
11
 
11
- 1. Copy blog_controller.rb to "app/controllers" in a Rails project.
12
+ 1. Copy the "apis" directory and its files into "app" in a Rails project.
12
13
 
14
+ 2. Copy the "controllers" directory and its files into "app" in a Rails project
13
15
 
14
- 2. Fire up a desktop blogging application (such as BloGTK on Linux),
15
- point it at http://localhost:3000/blog/api, and try creating or
16
- editing blog posts.
16
+ 3. Fire up a desktop blogging application (such as w.bloggar, MarsEdit, or BloGTK),
17
+ point it at http://localhost:3000/xmlrpc/api, and try creating or editing blog posts.
@@ -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
@@ -28,7 +28,7 @@ module ActionWebService # :nodoc:
28
28
  else
29
29
  return_value = nil
30
30
  end
31
- body = @encoder.encode_rpc_response(method_name, return_value)
31
+ body = @encoder.encode_rpc_response(method_name + 'Response', return_value)
32
32
  Response.new(body, 'text/xml')
33
33
  end
34
34
 
@@ -46,6 +46,7 @@ module ActionWebService # :nodoc:
46
46
  return nil unless request.method == :post
47
47
  soap_action = request.env['HTTP_SOAPACTION']
48
48
  return nil unless soap_action
49
+ soap_action = soap_action.dup
49
50
  soap_action.gsub!(/^"/, '')
50
51
  soap_action.gsub!(/"$/, '')
51
52
  soap_action.strip!
@@ -1,7 +1,7 @@
1
1
  require 'test/unit'
2
2
 
3
- module Test
4
- module Unit
3
+ module Test # :nodoc:
4
+ module Unit # :nodoc:
5
5
  class TestCase # :nodoc:
6
6
  private
7
7
  # invoke the specified API method
@@ -23,7 +23,7 @@ module WS
23
23
  if param.value.is_a?(Exception)
24
24
  detail = SOAP::Mapping::SOAPException.new(param.value)
25
25
  soap_obj = SOAP::SOAPFault.new(
26
- SOAP::SOAPString.new('Server'),
26
+ SOAP::SOAPQName.new('%s:%s' % [SOAP::SOAPNamespaceTag, 'Server']),
27
27
  SOAP::SOAPString.new(param.value.to_s),
28
28
  SOAP::SOAPString.new(self.class.name),
29
29
  SOAP::Mapping.obj2soap(detail))
@@ -146,6 +146,9 @@ module WS
146
146
  value.to_s
147
147
  when :bool
148
148
  return false if value.nil?
149
+ int_value = Integer(value) rescue nil
150
+ return true if int_value == 1
151
+ return false if int_value == 0
149
152
  value = value.to_s
150
153
  return true if value == 'true'
151
154
  return false if value == 'false'
@@ -27,6 +27,8 @@ class TypesTest < Test::Unit::TestCase
27
27
  assert_equal('50.0', @caster.cast(50.0, String))
28
28
  assert_equal(true, @caster.cast('true', FalseClass))
29
29
  assert_equal(false, @caster.cast('false', TrueClass))
30
+ assert_equal(true, @caster.cast(1, FalseClass))
31
+ assert_equal(false, @caster.cast(0, TrueClass))
30
32
  assert_raises(TypeError) do
31
33
  @caster.cast('yes', FalseClass)
32
34
  end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.6
2
+ rubygems_version: 0.8.8
3
3
  specification_version: 1
4
4
  name: actionwebservice
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.6.0
7
- date: 2005-03-07
6
+ version: 0.6.1
7
+ date: 2005-03-22
8
8
  summary: Web service support for Action Pack.
9
9
  require_paths:
10
10
  - lib
@@ -45,8 +45,14 @@ files:
45
45
  - examples/googlesearch/delegated/search_controller.rb
46
46
  - examples/googlesearch/direct/google_search_api.rb
47
47
  - examples/googlesearch/direct/search_controller.rb
48
- - examples/metaWeblog/blog_controller.rb
48
+ - examples/metaWeblog/apis
49
+ - examples/metaWeblog/controllers
49
50
  - examples/metaWeblog/README
51
+ - examples/metaWeblog/apis/blogger_api.rb
52
+ - examples/metaWeblog/apis/blogger_service.rb
53
+ - examples/metaWeblog/apis/meta_weblog_api.rb
54
+ - examples/metaWeblog/apis/meta_weblog_service.rb
55
+ - examples/metaWeblog/controllers/xmlrpc_controller.rb
50
56
  - lib/action_web_service
51
57
  - lib/action_web_service.rb
52
58
  - lib/action_web_service/api
@@ -134,9 +140,9 @@ dependencies:
134
140
  version_requirements: !ruby/object:Gem::Version::Requirement
135
141
  requirements:
136
142
  -
137
- - ">="
143
+ - "="
138
144
  - !ruby/object:Gem::Version
139
- version: 1.5.1
145
+ version: 1.6.0
140
146
  version:
141
147
  - !ruby/object:Gem::Dependency
142
148
  name: activerecord
@@ -144,9 +150,9 @@ dependencies:
144
150
  version_requirements: !ruby/object:Gem::Version::Requirement
145
151
  requirements:
146
152
  -
147
- - ">="
153
+ - "="
148
154
  - !ruby/object:Gem::Version
149
- version: 1.8.0
155
+ version: 1.9.0
150
156
  version:
151
157
  - !ruby/object:Gem::Dependency
152
158
  name: activesupport
@@ -154,7 +160,7 @@ dependencies:
154
160
  version_requirements: !ruby/object:Gem::Version::Requirement
155
161
  requirements:
156
162
  -
157
- - ">="
163
+ - "="
158
164
  - !ruby/object:Gem::Version
159
- version: 1.0.1
165
+ version: 1.0.2
160
166
  version:
@@ -1,127 +0,0 @@
1
- # point your client at http://project_url/blog/api to test
2
- # this
3
-
4
- # structures as defined by the metaWeblog/blogger
5
- # specifications.
6
- module Blog
7
- class Enclosure < ActionWebService::Struct
8
- member :url, :string
9
- member :length, :int
10
- member :type, :string
11
- end
12
-
13
- class Source < ActionWebService::Struct
14
- member :url, :string
15
- member :name, :string
16
- end
17
-
18
- class Post < ActionWebService::Struct
19
- member :title, :string
20
- member :link, :string
21
- member :description, :string
22
- member :author, :string
23
- member :category, :string
24
- member :comments, :string
25
- member :enclosure, Enclosure
26
- member :guid, :string
27
- member :pubDate, :string
28
- member :source, Source
29
- end
30
-
31
- class Blog < ActionWebService::Struct
32
- member :url, :string
33
- member :blogid, :string
34
- member :blogName, :string
35
- end
36
- end
37
-
38
- # skeleton metaWeblog API
39
- class MetaWeblogAPI < ActionWebService::API::Base
40
- inflect_names false
41
-
42
- api_method :newPost, :returns => [:string], :expects => [
43
- {:blogid=>:string},
44
- {:username=>:string},
45
- {:password=>:string},
46
- {:struct=>Blog::Post},
47
- {:publish=>:bool},
48
- ]
49
-
50
- api_method :editPost, :returns => [:bool], :expects => [
51
- {:postid=>:string},
52
- {:username=>:string},
53
- {:password=>:string},
54
- {:struct=>Blog::Post},
55
- {:publish=>:bool},
56
- ]
57
-
58
- api_method :getPost, :returns => [Blog::Post], :expects => [
59
- {:postid=>:string},
60
- {:username=>:string},
61
- {:password=>:string},
62
- ]
63
-
64
- api_method :getUsersBlogs, :returns => [[Blog::Blog]], :expects => [
65
- {:appkey=>:string},
66
- {:username=>:string},
67
- {:password=>:string},
68
- ]
69
-
70
- api_method :getRecentPosts, :returns => [[Blog::Post]], :expects => [
71
- {:blogid=>:string},
72
- {:username=>:string},
73
- {:password=>:string},
74
- {:numberOfPosts=>:int},
75
- ]
76
- end
77
-
78
- class BlogController < ApplicationController
79
- web_service_api MetaWeblogAPI
80
-
81
- def initialize
82
- @postid = 0
83
- end
84
-
85
- def newPost
86
- $stderr.puts 'Creating post: username=%s password=%s struct=%s' % [
87
- @params['username'],
88
- @params['password'],
89
- @params['struct'].inspect
90
- ]
91
- (@postid += 1).to_s
92
- end
93
-
94
- def editPost
95
- $stderr.puts 'Editing post: username=%s password=%s struct=%s' % [
96
- @params['username'],
97
- @params['password'],
98
- @params['struct'].inspect
99
- ]
100
- true
101
- end
102
-
103
- def getUsersBlogs
104
- $stderr.puts "Returning user %s's blogs" % @params['username']
105
- blog = Blog::Blog.new(
106
- :url =>'http://blog.xeraph.org',
107
- :blogid => 'sttm',
108
- :blogName => 'slave to the machine'
109
- )
110
- [blog]
111
- end
112
-
113
- def getRecentPosts
114
- $stderr.puts "Returning recent posts (%d requested)" % @params['numberOfPosts']
115
- post1 = Blog::Post.new(
116
- :title => 'first post!',
117
- :link => 'http://blog.xeraph.org/testOne.html',
118
- :description => 'this is the first post'
119
- )
120
- post2 = Blog::Post.new(
121
- :title => 'second post!',
122
- :link => 'http://blog.xeraph.org/testTwo.html',
123
- :description => 'this is the second post'
124
- )
125
- [post1, post2]
126
- end
127
- end