nogara-wash_out 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/.travis.yml +3 -0
- data/Appraisals +7 -0
- data/CHANGELOG.md +79 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +118 -0
- data/LICENSE +22 -0
- data/README.md +181 -0
- data/Rakefile +14 -0
- data/app/helpers/wash_out_helper.rb +64 -0
- data/app/views/wash_with_soap/error.builder +10 -0
- data/app/views/wash_with_soap/response.builder +13 -0
- data/app/views/wash_with_soap/wsdl.builder +68 -0
- data/gemfiles/rails-3.0.11.gemfile +8 -0
- data/gemfiles/rails-3.0.11.gemfile.lock +130 -0
- data/gemfiles/rails-3.1.3.gemfile +8 -0
- data/gemfiles/rails-3.1.3.gemfile.lock +141 -0
- data/init.rb +1 -0
- data/lib/wash_out.rb +35 -0
- data/lib/wash_out/dispatcher.rb +206 -0
- data/lib/wash_out/engine.rb +30 -0
- data/lib/wash_out/model.rb +25 -0
- data/lib/wash_out/param.rb +176 -0
- data/lib/wash_out/router.rb +36 -0
- data/lib/wash_out/soap.rb +40 -0
- data/lib/wash_out/type.rb +28 -0
- data/lib/wash_out/version.rb +3 -0
- data/lib/wash_out/wsse.rb +79 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +42 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +23 -0
- data/spec/dummy/config/environments/test.rb +30 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/spec_helper.rb +51 -0
- data/spec/support/httpi-rack.rb +46 -0
- data/spec/wash_out/dispatcher_spec.rb +65 -0
- data/spec/wash_out/param_spec.rb +26 -0
- data/spec/wash_out/type_spec.rb +23 -0
- data/spec/wash_out_spec.rb +686 -0
- data/wash_out.gemspec +21 -0
- metadata +183 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Appraisals
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 0.5.2
|
4
|
+
|
5
|
+
* .NET-compliant response tags [@ebeigarts][]
|
6
|
+
* Tiny fixes [@ebeigarts][]
|
7
|
+
|
8
|
+
## 0.5.1
|
9
|
+
|
10
|
+
* Better routing points [@inossidabile][]
|
11
|
+
|
12
|
+
## 0.5.0
|
13
|
+
|
14
|
+
* WSSE password authentication [@dhinus][]
|
15
|
+
* Ruby 1.8 compatibility restores [@dhinus][]
|
16
|
+
|
17
|
+
## 0.4.2
|
18
|
+
|
19
|
+
* SOAP hrefs are now supported [@inossidabile][]
|
20
|
+
* Better camelization: reusable types and methods are now supported [@inossidabile][]
|
21
|
+
|
22
|
+
## 0.4.1
|
23
|
+
|
24
|
+
* .NET-compliant :integer type WSDL [@inossidabile][]
|
25
|
+
|
26
|
+
## 0.4.0
|
27
|
+
|
28
|
+
* Better content-type for the response (#33) [@inossidabile][]
|
29
|
+
* Date type support (#18) [@inossidabile][]
|
30
|
+
* Avoid duplication of inner types [@inossidabile][]
|
31
|
+
* Output camelization support [@inossidabile][]
|
32
|
+
* External types declaration support (#21, #41) [@inossidabile][]
|
33
|
+
|
34
|
+
## 0.3.7
|
35
|
+
|
36
|
+
* Better empty parameters handling (#26, #30) [@rngtng][]
|
37
|
+
|
38
|
+
## 0.3.6
|
39
|
+
|
40
|
+
* Unicorn stream reading bug (#20)
|
41
|
+
* .NET minOccurs/maxOccurs basic WSDL compatibility (#22, #23)
|
42
|
+
|
43
|
+
## 0.3.5
|
44
|
+
|
45
|
+
* Very evil thread-safety bug fixed. You are encouraged to never use anything below this version.
|
46
|
+
|
47
|
+
## 0.3.4
|
48
|
+
|
49
|
+
* WSDL generation fixed to support complex structures for return values
|
50
|
+
* Configuration moved to OrderedOptions with proper Engine binding
|
51
|
+
* `snakecase` configuration directive added: if set to false, wash_out won't modify params keys
|
52
|
+
|
53
|
+
## 0.3.3
|
54
|
+
|
55
|
+
* Tiny fixes in wash_out behavior with inline arrays (#11, #12)
|
56
|
+
* Ability to change namespace
|
57
|
+
|
58
|
+
## 0.3.2
|
59
|
+
|
60
|
+
* WashOut doesn't check existance of parameters anymore you should do it yourself from now
|
61
|
+
* Proper handling of blank parameters (#10)
|
62
|
+
* Proper handling of complex structures inside arrays (#9)
|
63
|
+
* Response performance improved
|
64
|
+
|
65
|
+
## 0.3.1
|
66
|
+
|
67
|
+
* Support of complex structures inside array
|
68
|
+
* Better Nori handling (no more dependency on Savon hijacking)
|
69
|
+
|
70
|
+
## 0.3.0
|
71
|
+
|
72
|
+
* The syntax for empty set (no input params or output params) changed from [] to nil.
|
73
|
+
* SOAP response format improved. All results are now wrapped into tns:messages instead of soap:Body.
|
74
|
+
* Arrays (minOccurs/maxOccurs) are now supported with `:foo => [:integer]` syntax.
|
75
|
+
|
76
|
+
[@inossidabile]: https://twitter.com/#!/_inossidabile
|
77
|
+
[@rngtng]: https://github.com/rngtng
|
78
|
+
[@dhinus]: https://github.com/dhinus
|
79
|
+
[@ebeigarts]: https://github.com/ebeigarts
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
wash_out (0.5.2)
|
5
|
+
nori
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionpack (3.2.1)
|
11
|
+
activemodel (= 3.2.1)
|
12
|
+
activesupport (= 3.2.1)
|
13
|
+
builder (~> 3.0.0)
|
14
|
+
erubis (~> 2.7.0)
|
15
|
+
journey (~> 1.0.1)
|
16
|
+
rack (~> 1.4.0)
|
17
|
+
rack-cache (~> 1.1)
|
18
|
+
rack-test (~> 0.6.1)
|
19
|
+
sprockets (~> 2.1.2)
|
20
|
+
activemodel (3.2.1)
|
21
|
+
activesupport (= 3.2.1)
|
22
|
+
builder (~> 3.0.0)
|
23
|
+
activesupport (3.2.1)
|
24
|
+
i18n (~> 0.6)
|
25
|
+
multi_json (~> 1.0)
|
26
|
+
akami (1.0.0)
|
27
|
+
gyoku (>= 0.4.0)
|
28
|
+
appraisal (0.4.1)
|
29
|
+
bundler
|
30
|
+
rake
|
31
|
+
builder (3.0.0)
|
32
|
+
coderay (1.0.5)
|
33
|
+
diff-lcs (1.1.3)
|
34
|
+
erubis (2.7.0)
|
35
|
+
gyoku (0.4.4)
|
36
|
+
builder (>= 2.1.2)
|
37
|
+
hike (1.2.1)
|
38
|
+
httpi (0.9.6)
|
39
|
+
rack
|
40
|
+
i18n (0.6.0)
|
41
|
+
journey (1.0.3)
|
42
|
+
json (1.6.5)
|
43
|
+
json (1.6.5-java)
|
44
|
+
method_source (0.7.1)
|
45
|
+
multi_json (1.1.0)
|
46
|
+
nokogiri (1.5.0)
|
47
|
+
nokogiri (1.5.0-java)
|
48
|
+
nori (1.1.0)
|
49
|
+
pry (0.9.8.4)
|
50
|
+
coderay (~> 1.0.5)
|
51
|
+
method_source (~> 0.7.1)
|
52
|
+
slop (>= 2.4.4, < 3)
|
53
|
+
pry (0.9.8.4-java)
|
54
|
+
coderay (~> 1.0.5)
|
55
|
+
method_source (~> 0.7.1)
|
56
|
+
slop (>= 2.4.4, < 3)
|
57
|
+
spoon (~> 0.0)
|
58
|
+
rack (1.4.1)
|
59
|
+
rack-cache (1.1)
|
60
|
+
rack (>= 0.4)
|
61
|
+
rack-ssl (1.3.2)
|
62
|
+
rack
|
63
|
+
rack-test (0.6.1)
|
64
|
+
rack (>= 1.0)
|
65
|
+
railties (3.2.1)
|
66
|
+
actionpack (= 3.2.1)
|
67
|
+
activesupport (= 3.2.1)
|
68
|
+
rack-ssl (~> 1.3.2)
|
69
|
+
rake (>= 0.8.7)
|
70
|
+
rdoc (~> 3.4)
|
71
|
+
thor (~> 0.14.6)
|
72
|
+
rake (0.9.2.2)
|
73
|
+
rdoc (3.12)
|
74
|
+
json (~> 1.4)
|
75
|
+
rspec (2.8.0)
|
76
|
+
rspec-core (~> 2.8.0)
|
77
|
+
rspec-expectations (~> 2.8.0)
|
78
|
+
rspec-mocks (~> 2.8.0)
|
79
|
+
rspec-core (2.8.0)
|
80
|
+
rspec-expectations (2.8.0)
|
81
|
+
diff-lcs (~> 1.1.2)
|
82
|
+
rspec-mocks (2.8.0)
|
83
|
+
rspec-rails (2.8.1)
|
84
|
+
actionpack (>= 3.0)
|
85
|
+
activesupport (>= 3.0)
|
86
|
+
railties (>= 3.0)
|
87
|
+
rspec (~> 2.8.0)
|
88
|
+
savon (0.9.9)
|
89
|
+
akami (~> 1.0)
|
90
|
+
builder (>= 2.1.2)
|
91
|
+
gyoku (>= 0.4.0)
|
92
|
+
httpi (~> 0.9)
|
93
|
+
nokogiri (>= 1.4.0)
|
94
|
+
nori (~> 1.1)
|
95
|
+
wasabi (~> 2.1)
|
96
|
+
slop (2.4.4)
|
97
|
+
spoon (0.0.1)
|
98
|
+
sprockets (2.1.2)
|
99
|
+
hike (~> 1.2)
|
100
|
+
rack (~> 1.0)
|
101
|
+
tilt (~> 1.1, != 1.3.0)
|
102
|
+
thor (0.14.6)
|
103
|
+
tilt (1.3.3)
|
104
|
+
tzinfo (0.3.31)
|
105
|
+
wasabi (2.1.0)
|
106
|
+
nokogiri (>= 1.4.0)
|
107
|
+
|
108
|
+
PLATFORMS
|
109
|
+
java
|
110
|
+
ruby
|
111
|
+
|
112
|
+
DEPENDENCIES
|
113
|
+
appraisal
|
114
|
+
pry
|
115
|
+
rspec-rails
|
116
|
+
savon
|
117
|
+
tzinfo
|
118
|
+
wash_out!
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2012 Round Lake, inc.,
|
4
|
+
Peter Zotov <whitequark@whitequark.org>.
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
14
|
+
all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
# WashOut
|
2
|
+
|
3
|
+
WashOut is a gem that greatly simplifies creation of SOAP service providers.
|
4
|
+
|
5
|
+
But if you have a chance, please [http://stopsoap.com/](http://stopsoap.com/).
|
6
|
+
|
7
|
+
## Compatibility
|
8
|
+
|
9
|
+
Rails >3.0 only.
|
10
|
+
|
11
|
+
WashOut should work like a charm on CRuby 1.9.x.
|
12
|
+
|
13
|
+
![Travis CI](https://secure.travis-ci.org/roundlake/wash_out.png)
|
14
|
+
|
15
|
+
We do support CRuby 1.8.7. However it is not a goal and it is not well supported by our specs. According to
|
16
|
+
this fact it maybe sometimes broken from the start on major releases. You are welcome to hold on an old
|
17
|
+
version and give us enough issues and pull-requests to make it work.
|
18
|
+
|
19
|
+
All dependencies are JRuby-compatible so again it will work well in --1.9 mode but it can fail with
|
20
|
+
fresh releases if you go --1.8.
|
21
|
+
|
22
|
+
## Installation
|
23
|
+
|
24
|
+
In your Gemfile, add this line:
|
25
|
+
|
26
|
+
gem 'wash_out'
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
A SOAP endpoint in WashOut is simply a Rails controller which includes the module WashOut::SOAP. Each SOAP
|
31
|
+
action corresponds to a certain controller method; this mapping, as well as the argument definition, is defined
|
32
|
+
by [soap_action][] method. Check the method documentation for complete info; here, only a few examples will be
|
33
|
+
demonstrated.
|
34
|
+
|
35
|
+
[soap_action]: http://rubydoc.info/gems/wash_out/WashOut/SOAP/ClassMethods#soap_action-instance_method
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
# app/controllers/rumbas_controller.rb
|
39
|
+
class RumbasController < ApplicationController
|
40
|
+
include WashOut::SOAP
|
41
|
+
|
42
|
+
# Simple case
|
43
|
+
soap_action "integer_to_string",
|
44
|
+
:args => :integer,
|
45
|
+
:return => :string
|
46
|
+
def integer_to_string
|
47
|
+
render :soap => params[:value].to_s
|
48
|
+
end
|
49
|
+
|
50
|
+
soap_action "concat",
|
51
|
+
:args => { :a => :string, :b => :string },
|
52
|
+
:return => :string
|
53
|
+
def concat
|
54
|
+
render :soap => (params[:a] + params[:b])
|
55
|
+
end
|
56
|
+
|
57
|
+
# Complex structures
|
58
|
+
soap_action "AddCircle",
|
59
|
+
:args => { :circle => { :center => { :x => :integer,
|
60
|
+
:y => :integer },
|
61
|
+
:radius => :double } },
|
62
|
+
:return => nil, # [] for wash_out below 0.3.0
|
63
|
+
:to => :add_circle
|
64
|
+
def add_circle
|
65
|
+
circle = params[:circle]
|
66
|
+
|
67
|
+
raise SOAPError, "radius is too small" if circle[:radius] < 3.0
|
68
|
+
|
69
|
+
Circle.new(circle[:center][:x], circle[:center][:y], circle[:radius])
|
70
|
+
|
71
|
+
render :soap => nil
|
72
|
+
end
|
73
|
+
|
74
|
+
# Arrays
|
75
|
+
soap_action "integers_to_boolean",
|
76
|
+
:args => { :data => [:integer] },
|
77
|
+
:return => [:boolean]
|
78
|
+
def integers_to_boolean
|
79
|
+
render :soap => params[:data].map{|x| x ? 1 : 0}
|
80
|
+
end
|
81
|
+
|
82
|
+
# You can use all Rails features like filtering, too. A SOAP controller
|
83
|
+
# is just like a normal controller with a special routing.
|
84
|
+
before_filter :dump_parameters
|
85
|
+
def dump_parameters
|
86
|
+
Rails.logger.debug params.inspect
|
87
|
+
end
|
88
|
+
end
|
89
|
+
```
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
# config/routes.rb
|
93
|
+
WashOutSample::Application.routes.draw do
|
94
|
+
wash_out :rumbas
|
95
|
+
end
|
96
|
+
```
|
97
|
+
|
98
|
+
In such a setup, the generated WSDL may be queried at path `/api/wsdl`. So, with a
|
99
|
+
gem like Savon, a request can be done using this path:
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
require 'savon'
|
103
|
+
|
104
|
+
client = Savon::Client.new("http://localhost:3000/rumbas/wsdl")
|
105
|
+
|
106
|
+
client.wsdl.soap_actions # => [:integer_to_string, :concat, :add_circle]
|
107
|
+
|
108
|
+
result = client.request(:concat) do
|
109
|
+
soap.body = { :a => "123", :b => "abc" }
|
110
|
+
end
|
111
|
+
|
112
|
+
# actual wash_out
|
113
|
+
result.to_hash # => {:concat_reponse => {:value=>"123abc"}}
|
114
|
+
|
115
|
+
# wash_out below 0.3.0 (and this is malformed response so please update)
|
116
|
+
result.to_hash # => {:value=>"123abc"}
|
117
|
+
```
|
118
|
+
|
119
|
+
Take a look at [WashOut sample application](https://github.com/roundlake/wash_out-sample).
|
120
|
+
|
121
|
+
## Reusable types
|
122
|
+
|
123
|
+
Basic inline types definition is fast and furious for the simple cases. You have an option to describe SOAP types
|
124
|
+
inside separate classes for the complex ones. Here's the way to do that:
|
125
|
+
|
126
|
+
```ruby
|
127
|
+
class Fluffy < WashOut::Type
|
128
|
+
map :universe => {
|
129
|
+
:name => :string,
|
130
|
+
:age => :int
|
131
|
+
}
|
132
|
+
end
|
133
|
+
|
134
|
+
class FluffyContainer < WashOut::Type
|
135
|
+
type_name 'fluffy_con'
|
136
|
+
map :fluffy => Fluffy
|
137
|
+
end
|
138
|
+
```
|
139
|
+
|
140
|
+
To use defined type inside your inline declaration, pass the class instead of type symbol (`:fluffy => Fluffy`).
|
141
|
+
|
142
|
+
Note that WashOut extends the `ActiveRecord` so every model you use is already a WashOut::Type and can be used
|
143
|
+
inside your interface declarations.
|
144
|
+
|
145
|
+
## Configuration
|
146
|
+
|
147
|
+
Use `config.wash_out...` inside your environment configuration to setup WashOut.
|
148
|
+
|
149
|
+
Available properties are:
|
150
|
+
|
151
|
+
* **namespace**: SOAP namespace to use. Default is `urn:WashOut`.
|
152
|
+
* **snakecase**: *(DEPRECATED SINCE 0.4.0)* Determines if WashOut should modify parameters keys to snakecase. Default is `false`.
|
153
|
+
* **snakecase_input**: Determines if WashOut should modify parameters keys to snakecase. Default is `false`.
|
154
|
+
* **camelize_wsdl**: Determinse if WashOut should camelize types within WSDL and responses. Default is `false`.
|
155
|
+
|
156
|
+
### Camelization
|
157
|
+
|
158
|
+
Note that WSDL camelization will affect method names but only if they were given as a symbol:
|
159
|
+
|
160
|
+
```ruby
|
161
|
+
soap_action :foo # this will be affected
|
162
|
+
soap_action "foo" # this will be passed as is
|
163
|
+
```
|
164
|
+
|
165
|
+
## Credits
|
166
|
+
|
167
|
+
<img src="http://roundlake.ru/assets/logo.png" align="right" />
|
168
|
+
|
169
|
+
* Boris Staal ([@_inossidabile](http://twitter.com/#!/_inossidabile))
|
170
|
+
* Peter Zotov ([@whitequark](http://twitter.com/#!/whitequark))
|
171
|
+
|
172
|
+
## Contributors
|
173
|
+
|
174
|
+
* Björn Nilsson ([@Bjorn-Nilsson](https://github.com/Bjorn-Nilsson))
|
175
|
+
* Tobias Bielohlawek ([@rngtng](https://github.com/rngtng))
|
176
|
+
* Francesco Negri ([@dhinus](https://github.com/dhinus))
|
177
|
+
* Edgars Beigarts ([@ebeigarts](https://github.com/ebeigarts))
|
178
|
+
|
179
|
+
## LICENSE
|
180
|
+
|
181
|
+
It is free software, and may be redistributed under the terms of MIT license.
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'appraisal'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
desc "Default: run the unit tests."
|
9
|
+
task :default => [:all]
|
10
|
+
|
11
|
+
desc 'Test the plugin under all supported Rails versions.'
|
12
|
+
task :all => ["appraisal:install"] do |t|
|
13
|
+
exec('rake appraisal spec')
|
14
|
+
end
|