wash_out 0.9.2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +23 -4
- data/Appraisals +2 -4
- data/Gemfile +1 -1
- data/README.md +38 -0
- data/Rakefile +6 -7
- data/app/helpers/wash_out_helper.rb +49 -18
- data/app/views/{wash_with_soap → wash_out}/document/error.builder +0 -0
- data/app/views/{wash_with_soap → wash_out}/document/response.builder +0 -0
- data/app/views/{wash_with_soap → wash_out}/document/wsdl.builder +13 -13
- data/app/views/{wash_with_soap → wash_out}/rpc/error.builder +0 -0
- data/app/views/{wash_with_soap → wash_out}/rpc/response.builder +0 -0
- data/app/views/{wash_with_soap → wash_out}/rpc/wsdl.builder +14 -14
- data/gemfiles/rails_3.1.3.gemfile +20 -0
- data/gemfiles/rails_3.2.12.gemfile +20 -0
- data/gemfiles/rails_4.0.0.gemfile +19 -0
- data/gemfiles/rails_4.1.0.gemfile +19 -0
- data/gemfiles/rails_4.2.0.gemfile +19 -0
- data/lib/wash_out/dispatcher.rb +28 -18
- data/lib/wash_out/param.rb +14 -2
- data/lib/wash_out/router.rb +5 -5
- data/lib/wash_out/soap.rb +1 -0
- data/lib/wash_out/version.rb +1 -1
- data/lib/wash_out/wsse.rb +3 -3
- data/lib/wash_out.rb +6 -0
- data/spec/dummy/config/environments/test.rb +1 -0
- data/spec/lib/wash_out/dispatcher_spec.rb +15 -15
- data/spec/lib/wash_out/middleware_spec.rb +8 -8
- data/spec/lib/wash_out/param_spec.rb +43 -11
- data/spec/lib/wash_out/type_spec.rb +9 -9
- data/spec/lib/wash_out_spec.rb +111 -96
- data/spec/spec_helper.rb +2 -0
- metadata +14 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a23248a1bd38c14fe7eae75c2589b4eb945687f6
|
4
|
+
data.tar.gz: 5f806cadfebf37d0b46ee2d7f69d00266f0bae53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5879036aca9ca31804573e45c5cc3aa4f7ffdb5303c27ea195c322c9246afd1ecde6d518783cd6e13dcd49ccb7a29c99f7017bc28a8feb43fbb45afeb2988063
|
7
|
+
data.tar.gz: d791bece6a7eb059ff83dbac5bce07ccd6e7dfc95c761579ff53ff97776dae4c7a5156b76997131f8de931b5263ba846545ec5018daa75eeb66faf985bbb2a6e
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,7 +1,26 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
script: bundle exec rspec
|
2
|
+
gemfile:
|
3
|
+
- gemfiles/rails_3.1.3.gemfile
|
4
|
+
- gemfiles/rails_3.2.12.gemfile
|
5
|
+
- gemfiles/rails_4.0.0.gemfile
|
6
|
+
- gemfiles/rails_4.1.0.gemfile
|
7
|
+
- gemfiles/rails_4.2.0.gemfile
|
3
8
|
rvm:
|
4
9
|
- 1.9.3
|
5
|
-
- jruby-19mode
|
6
10
|
- 2.0.0
|
7
|
-
- 2.1.
|
11
|
+
- 2.1.8
|
12
|
+
- 2.2.4
|
13
|
+
- 2.3.0
|
14
|
+
- jruby
|
15
|
+
matrix:
|
16
|
+
exclude:
|
17
|
+
- rvm: 2.2.4
|
18
|
+
gemfile: gemfiles/rails_3.1.3.gemfile
|
19
|
+
- rvm: 2.2.4
|
20
|
+
gemfile: gemfiles/rails_3.2.12.gemfile
|
21
|
+
- rvm: 2.3.0
|
22
|
+
gemfile: gemfiles/rails_3.1.3.gemfile
|
23
|
+
- rvm: 2.3.0
|
24
|
+
gemfile: gemfiles/rails_3.2.12.gemfile
|
25
|
+
before_install:
|
26
|
+
- gem update bundler
|
data/Appraisals
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -78,6 +78,44 @@ class RumbasController < ApplicationController
|
|
78
78
|
render :soap => params[:data].map{|x| x ? 1 : 0}
|
79
79
|
end
|
80
80
|
|
81
|
+
# Params from XML attributes;
|
82
|
+
# e.g. for a request to the 'AddCircle' action:
|
83
|
+
# <soapenv:Envelope>
|
84
|
+
# <soapenv:Body>
|
85
|
+
# <AddCircle>
|
86
|
+
# <Circle radius="5.0">
|
87
|
+
# <Center x="10" y="12" />
|
88
|
+
# </Circle>
|
89
|
+
# </AddCircle>
|
90
|
+
# </soapenv:Body>
|
91
|
+
# </soapenv:Envelope>
|
92
|
+
soap_action "AddCircle",
|
93
|
+
:args => { :circle => { :center => { :@x => :integer,
|
94
|
+
:@y => :integer },
|
95
|
+
:@radius => :double } },
|
96
|
+
:return => nil, # [] for wash_out below 0.3.0
|
97
|
+
:to => :add_circle
|
98
|
+
def add_circle
|
99
|
+
circle = params[:circle]
|
100
|
+
Circle.new(circle[:center][:x], circle[:center][:y], circle[:radius])
|
101
|
+
|
102
|
+
render :soap => nil
|
103
|
+
end
|
104
|
+
|
105
|
+
# With a customised input tag name, in case params are wrapped;
|
106
|
+
# e.g. for a request to the 'IntegersToBoolean' action:
|
107
|
+
# <soapenv:Envelope>
|
108
|
+
# <soapenv:Body>
|
109
|
+
# <MyRequest> <!-- not <IntegersToBoolean> -->
|
110
|
+
# <Data>...</Data>
|
111
|
+
# </MyRequest>
|
112
|
+
# </soapenv:Body>
|
113
|
+
# </soapenv:Envelope>
|
114
|
+
soap_action "integers_to_boolean",
|
115
|
+
:args => { :my_request => { :data => [:integer] } },
|
116
|
+
:as => 'MyRequest',
|
117
|
+
:return => [:boolean]
|
118
|
+
|
81
119
|
# You can use all Rails features like filtering, too. A SOAP controller
|
82
120
|
# is just like a normal controller with a special routing.
|
83
121
|
before_filter :dump_parameters
|
data/Rakefile
CHANGED
@@ -5,10 +5,9 @@ require 'rspec/core/rake_task'
|
|
5
5
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
8
|
+
task :console do
|
9
|
+
require "action_controller/railtie"
|
10
|
+
require "rails/test_unit/railtie"
|
11
|
+
Bundler.require
|
12
|
+
binding.pry
|
13
|
+
end
|
@@ -9,31 +9,47 @@ module WashOutHelper
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
def wsdl_data_attrs(param)
|
13
|
+
param.map.reduce({}) do |memo, p|
|
14
|
+
if p.respond_to?(:attribute?) && p.attribute?
|
15
|
+
memo.merge p.attr_name => p.value
|
16
|
+
else
|
17
|
+
memo
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
12
22
|
def wsdl_data(xml, params)
|
13
23
|
params.each do |param|
|
24
|
+
next if param.attribute?
|
25
|
+
|
14
26
|
tag_name = param.name
|
15
27
|
param_options = wsdl_data_options(param)
|
28
|
+
param_options.merge! wsdl_data_attrs(param)
|
16
29
|
|
17
|
-
if
|
18
|
-
if
|
19
|
-
|
30
|
+
if param.struct?
|
31
|
+
if param.multiplied
|
32
|
+
param.map.each do |p|
|
33
|
+
attrs = wsdl_data_attrs p
|
34
|
+
if p.is_a?(Array) || p.map.size > attrs.size
|
35
|
+
blk = proc { wsdl_data(xml, p.map) }
|
36
|
+
end
|
37
|
+
attrs.reject! { |_, v| v.nil? }
|
38
|
+
xml.tag! tag_name, param_options.merge(attrs), &blk
|
39
|
+
end
|
20
40
|
else
|
21
|
-
|
22
|
-
|
23
|
-
xml.tag! tag_name, v, param_options
|
41
|
+
xml.tag! tag_name, param_options do
|
42
|
+
wsdl_data(xml, param.map)
|
24
43
|
end
|
25
44
|
end
|
26
45
|
else
|
27
|
-
if
|
28
|
-
|
29
|
-
|
46
|
+
if param.multiplied
|
47
|
+
param.value = [] unless param.value.is_a?(Array)
|
48
|
+
param.value.each do |v|
|
49
|
+
xml.tag! tag_name, v, param_options
|
30
50
|
end
|
31
51
|
else
|
32
|
-
param.
|
33
|
-
xml.tag! tag_name, param_options do
|
34
|
-
wsdl_data(xml, p.map)
|
35
|
-
end
|
36
|
-
end
|
52
|
+
xml.tag! tag_name, param.value, param_options
|
37
53
|
end
|
38
54
|
end
|
39
55
|
end
|
@@ -45,12 +61,27 @@ module WashOutHelper
|
|
45
61
|
if param.struct?
|
46
62
|
if !defined.include?(param.basic_type)
|
47
63
|
xml.tag! "xsd:complexType", :name => param.basic_type do
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
64
|
+
attrs, elems = [], []
|
65
|
+
param.map.each do |value|
|
66
|
+
more << value if value.struct?
|
67
|
+
if value.attribute?
|
68
|
+
attrs << value
|
69
|
+
else
|
70
|
+
elems << value
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
if elems.any?
|
75
|
+
xml.tag! "xsd:sequence" do
|
76
|
+
elems.each do |value|
|
77
|
+
xml.tag! "xsd:element", wsdl_occurence(value, false, :name => value.name, :type => value.namespaced_type)
|
78
|
+
end
|
52
79
|
end
|
53
80
|
end
|
81
|
+
|
82
|
+
attrs.each do |value|
|
83
|
+
xml.tag! "xsd:attribute", wsdl_occurence(value, false, :name => value.attr_name, :type => value.namespaced_type)
|
84
|
+
end
|
54
85
|
end
|
55
86
|
|
56
87
|
defined << param.basic_type
|
File without changes
|
File without changes
|
@@ -19,6 +19,19 @@ xml.definitions 'xmlns' => 'http://schemas.xmlsoap.org/wsdl/',
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
@map.each do |operation, formats|
|
23
|
+
xml.message :name => "#{operation}" do
|
24
|
+
formats[:in].each do |p|
|
25
|
+
xml.part wsdl_occurence(p, false, :name => p.name, :type => p.namespaced_type)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
xml.message :name => formats[:response_tag] do
|
29
|
+
formats[:out].each do |p|
|
30
|
+
xml.part wsdl_occurence(p, false, :name => p.name, :type => p.namespaced_type)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
22
35
|
xml.portType :name => "#{@name}_port" do
|
23
36
|
@map.each do |operation, formats|
|
24
37
|
xml.operation :name => operation do
|
@@ -52,17 +65,4 @@ xml.definitions 'xmlns' => 'http://schemas.xmlsoap.org/wsdl/',
|
|
52
65
|
xml.tag! "soap:address", :location => send("#{@name}_action_url")
|
53
66
|
end
|
54
67
|
end
|
55
|
-
|
56
|
-
@map.each do |operation, formats|
|
57
|
-
xml.message :name => "#{operation}" do
|
58
|
-
formats[:in].each do |p|
|
59
|
-
xml.part wsdl_occurence(p, false, :name => p.name, :type => p.namespaced_type)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
xml.message :name => formats[:response_tag] do
|
63
|
-
formats[:out].each do |p|
|
64
|
-
xml.part wsdl_occurence(p, false, :name => p.name, :type => p.namespaced_type)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
68
|
end
|
File without changes
|
File without changes
|
@@ -19,6 +19,19 @@ xml.definitions 'xmlns' => 'http://schemas.xmlsoap.org/wsdl/',
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
@map.each do |operation, formats|
|
23
|
+
xml.message :name => "#{operation}" do
|
24
|
+
formats[:in].each do |p|
|
25
|
+
xml.part wsdl_occurence(p, true, :name => p.name, :type => p.namespaced_type)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
xml.message :name => formats[:response_tag] do
|
29
|
+
formats[:out].each do |p|
|
30
|
+
xml.part wsdl_occurence(p, true, :name => p.name, :type => p.namespaced_type)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
22
35
|
xml.portType :name => "#{@name}_port" do
|
23
36
|
@map.each do |operation, formats|
|
24
37
|
xml.operation :name => operation do
|
@@ -52,17 +65,4 @@ xml.definitions 'xmlns' => 'http://schemas.xmlsoap.org/wsdl/',
|
|
52
65
|
xml.tag! "soap:address", :location => send("#{@name}_action_url")
|
53
66
|
end
|
54
67
|
end
|
55
|
-
|
56
|
-
@map.each do |operation, formats|
|
57
|
-
xml.message :name => "#{operation}" do
|
58
|
-
formats[:in].each do |p|
|
59
|
-
xml.part wsdl_occurence(p, true, :name => p.name, :type => p.namespaced_type)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
xml.message :name => formats[:response_tag] do
|
63
|
-
formats[:out].each do |p|
|
64
|
-
xml.part wsdl_occurence(p, true, :name => p.name, :type => p.namespaced_type)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
68
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "http://rubygems.org"
|
4
|
+
|
5
|
+
gem "wasabi"
|
6
|
+
gem "savon", ">= 2.0.0"
|
7
|
+
gem "httpi"
|
8
|
+
gem "rspec-rails"
|
9
|
+
gem "guard"
|
10
|
+
gem "guard-rspec"
|
11
|
+
gem "rb-fsevent"
|
12
|
+
gem "appraisal"
|
13
|
+
gem "tzinfo"
|
14
|
+
gem "pry"
|
15
|
+
gem "simplecov"
|
16
|
+
gem "simplecov-summary"
|
17
|
+
gem "rails", "3.1.3"
|
18
|
+
gem "test-unit"
|
19
|
+
|
20
|
+
gemspec :path => "../"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "http://rubygems.org"
|
4
|
+
|
5
|
+
gem "wasabi"
|
6
|
+
gem "savon", ">= 2.0.0"
|
7
|
+
gem "httpi"
|
8
|
+
gem "rspec-rails"
|
9
|
+
gem "guard"
|
10
|
+
gem "guard-rspec"
|
11
|
+
gem "rb-fsevent"
|
12
|
+
gem "appraisal"
|
13
|
+
gem "tzinfo"
|
14
|
+
gem "pry"
|
15
|
+
gem "simplecov"
|
16
|
+
gem "simplecov-summary"
|
17
|
+
gem "rails", "3.2.12"
|
18
|
+
gem "test-unit"
|
19
|
+
|
20
|
+
gemspec :path => "../"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "http://rubygems.org"
|
4
|
+
|
5
|
+
gem "wasabi"
|
6
|
+
gem "savon", ">= 2.0.0"
|
7
|
+
gem "httpi"
|
8
|
+
gem "rspec-rails"
|
9
|
+
gem "guard"
|
10
|
+
gem "guard-rspec"
|
11
|
+
gem "rb-fsevent"
|
12
|
+
gem "appraisal"
|
13
|
+
gem "tzinfo"
|
14
|
+
gem "pry"
|
15
|
+
gem "simplecov"
|
16
|
+
gem "simplecov-summary"
|
17
|
+
gem "rails", "4.0.0"
|
18
|
+
|
19
|
+
gemspec :path => "../"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "http://rubygems.org"
|
4
|
+
|
5
|
+
gem "wasabi"
|
6
|
+
gem "savon", ">= 2.0.0"
|
7
|
+
gem "httpi"
|
8
|
+
gem "rspec-rails"
|
9
|
+
gem "guard"
|
10
|
+
gem "guard-rspec"
|
11
|
+
gem "rb-fsevent"
|
12
|
+
gem "appraisal"
|
13
|
+
gem "tzinfo"
|
14
|
+
gem "pry"
|
15
|
+
gem "simplecov"
|
16
|
+
gem "simplecov-summary"
|
17
|
+
gem "rails", "4.1.0"
|
18
|
+
|
19
|
+
gemspec :path => "../"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "http://rubygems.org"
|
4
|
+
|
5
|
+
gem "wasabi"
|
6
|
+
gem "savon", ">= 2.0.0"
|
7
|
+
gem "httpi"
|
8
|
+
gem "rspec-rails"
|
9
|
+
gem "guard"
|
10
|
+
gem "guard-rspec"
|
11
|
+
gem "rb-fsevent"
|
12
|
+
gem "appraisal"
|
13
|
+
gem "tzinfo"
|
14
|
+
gem "pry"
|
15
|
+
gem "simplecov"
|
16
|
+
gem "simplecov-summary"
|
17
|
+
gem "rails", "4.2.0"
|
18
|
+
|
19
|
+
gemspec :path => "../"
|
data/lib/wash_out/dispatcher.rb
CHANGED
@@ -32,22 +32,27 @@ module WashOut
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def _map_soap_parameters
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
value = hash[key].delete_if{|k, v| k.to_s[0] == '@'}
|
35
|
+
@_params = _load_params action_spec[:in],
|
36
|
+
_strip_empty_nodes(action_spec[:in], xml_data)
|
37
|
+
end
|
39
38
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
39
|
+
def _strip_empty_nodes(params, hash)
|
40
|
+
hash.keys.each do |key|
|
41
|
+
param = params.detect { |a| a.raw_name.to_s == key.to_s }
|
42
|
+
next if !(param && hash[key].is_a?(Hash))
|
43
|
+
|
44
|
+
value = hash[key].delete_if do |k, _|
|
45
|
+
k.to_s[0] == '@' && !param.map.detect { |a| a.raw_name.to_s == k.to_s }
|
46
46
|
end
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
if value.length > 0
|
49
|
+
hash[key] = _strip_empty_nodes param.map, value
|
50
|
+
else
|
51
|
+
hash[key] = nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
hash
|
51
56
|
end
|
52
57
|
|
53
58
|
# Creates the final parameter hash based on the request spec and xml_data from the request
|
@@ -69,7 +74,7 @@ module WashOut
|
|
69
74
|
@namespace = soap_config.namespace
|
70
75
|
@name = controller_path.gsub('/', '_')
|
71
76
|
|
72
|
-
render :template => "
|
77
|
+
render :template => "wash_out/#{soap_config.wsdl_style}/wsdl", :layout => false,
|
73
78
|
:content_type => 'text/xml'
|
74
79
|
end
|
75
80
|
|
@@ -124,7 +129,7 @@ module WashOut
|
|
124
129
|
return result_spec
|
125
130
|
}
|
126
131
|
|
127
|
-
render :template => "
|
132
|
+
render :template => "wash_out/#{soap_config.wsdl_style}/response",
|
128
133
|
:layout => false,
|
129
134
|
:locals => { :result => inject.call(result, @action_spec[:out]) },
|
130
135
|
:content_type => 'text/xml'
|
@@ -146,7 +151,7 @@ module WashOut
|
|
146
151
|
# Rails do not support sequental rescue_from handling, that is, rescuing an
|
147
152
|
# exception from a rescue_from handler. Hence this function is a public API.
|
148
153
|
def render_soap_error(message, code=nil)
|
149
|
-
render :template => "
|
154
|
+
render :template => "wash_out/#{soap_config.wsdl_style}/error", :status => 500,
|
150
155
|
:layout => false,
|
151
156
|
:locals => { :error_message => message, :error_code => (code || 'Server') },
|
152
157
|
:content_type => 'text/xml'
|
@@ -188,14 +193,19 @@ module WashOut
|
|
188
193
|
self.class.soap_actions[soap_action]
|
189
194
|
end
|
190
195
|
|
196
|
+
def request_input_tag
|
197
|
+
action_spec[:request_tag]
|
198
|
+
end
|
199
|
+
|
191
200
|
def soap_action
|
192
201
|
request.env['wash_out.soap_action']
|
193
202
|
end
|
194
203
|
|
195
204
|
def xml_data
|
196
205
|
xml_data = env['wash_out.soap_data'].values_at(:envelope, :Envelope).compact.first
|
197
|
-
xml_data = xml_data.values_at(:body, :Body).compact.first
|
198
|
-
xml_data
|
206
|
+
xml_data = xml_data.values_at(:body, :Body).compact.first || {}
|
207
|
+
return xml_data if soap_config.wsdl_style == "document"
|
208
|
+
xml_data = xml_data.values_at(soap_action.underscore.to_sym, soap_action.to_sym, request_input_tag.to_sym).compact.first || {}
|
199
209
|
end
|
200
210
|
|
201
211
|
end
|
data/lib/wash_out/param.rb
CHANGED
@@ -7,6 +7,7 @@ module WashOut
|
|
7
7
|
attr_accessor :multiplied
|
8
8
|
attr_accessor :value
|
9
9
|
attr_accessor :source_class
|
10
|
+
attr_accessor :soap_config
|
10
11
|
|
11
12
|
# Defines a WSDL parameter with name +name+ and type specifier +type+.
|
12
13
|
# The type specifier format is described in #parse_def.
|
@@ -63,6 +64,7 @@ module WashOut
|
|
63
64
|
operation = case type
|
64
65
|
when 'string'; :to_s
|
65
66
|
when 'integer'; :to_i
|
67
|
+
when 'long'; :to_i
|
66
68
|
when 'double'; :to_f
|
67
69
|
when 'boolean'; lambda{|dat| dat === "0" ? false : !!dat}
|
68
70
|
when 'date'; :to_date
|
@@ -160,10 +162,19 @@ module WashOut
|
|
160
162
|
def flat_copy
|
161
163
|
copy = self.class.new(@soap_config, @name, @type.to_sym, @multiplied)
|
162
164
|
copy.raw_name = raw_name
|
163
|
-
copy.source_class =
|
165
|
+
copy.source_class = source_class
|
164
166
|
copy
|
165
167
|
end
|
166
168
|
|
169
|
+
def attribute?
|
170
|
+
name[0] == "@"
|
171
|
+
end
|
172
|
+
|
173
|
+
def attr_name
|
174
|
+
raise 'Not attribute' unless attribute?
|
175
|
+
name[1..-1]
|
176
|
+
end
|
177
|
+
|
167
178
|
private
|
168
179
|
|
169
180
|
# Used to load an entire structure.
|
@@ -178,7 +189,8 @@ module WashOut
|
|
178
189
|
# RUBY18 Enumerable#each_with_object is better, but 1.9 only.
|
179
190
|
@map.map do |param|
|
180
191
|
if data.has_key? param.raw_name
|
181
|
-
|
192
|
+
param_name = param.attribute? ? param.attr_name : param.raw_name
|
193
|
+
struct[param_name] = yield param, data, param.raw_name
|
182
194
|
end
|
183
195
|
end
|
184
196
|
|
data/lib/wash_out/router.rb
CHANGED
@@ -52,11 +52,11 @@ module WashOut
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def soap_body(env)
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
55
|
+
body = env['rack.input']
|
56
|
+
body.rewind if body.respond_to? :rewind
|
57
|
+
body.respond_to?(:string) ? body.string : body.read
|
58
|
+
ensure
|
59
|
+
body.rewind if body.respond_to? :rewind
|
60
60
|
end
|
61
61
|
|
62
62
|
def parse_soap_parameters(env)
|
data/lib/wash_out/soap.rb
CHANGED
@@ -30,6 +30,7 @@ module WashOut
|
|
30
30
|
|
31
31
|
self.soap_actions[action] = options.merge(
|
32
32
|
:in => WashOut::Param.parse_def(soap_config, options[:args]),
|
33
|
+
:request_tag => options[:as] || action,
|
33
34
|
:out => WashOut::Param.parse_def(soap_config, options[:return]),
|
34
35
|
:to => options[:to] || action,
|
35
36
|
:response_tag => options[:response_tag] || default_response_tag
|
data/lib/wash_out/version.rb
CHANGED
data/lib/wash_out/wsse.rb
CHANGED
@@ -49,8 +49,8 @@ module WashOut
|
|
49
49
|
def matches_expected_digest?(password)
|
50
50
|
nonce = @username_token.values_at(:nonce, :Nonce).compact.first
|
51
51
|
timestamp = @username_token.values_at(:created, :Created).compact.first
|
52
|
-
|
53
52
|
return false if nonce.nil? || timestamp.nil?
|
53
|
+
timestamp = timestamp.to_datetime
|
54
54
|
|
55
55
|
# Token should not be accepted if timestamp is older than 5 minutes ago
|
56
56
|
# http://www.oasis-open.org/committees/download.php/16782/wss-v1.1-spec-os-UsernameTokenProfile.pdf
|
@@ -62,11 +62,11 @@ module WashOut
|
|
62
62
|
flavors = Array.new
|
63
63
|
|
64
64
|
# Ruby / Savon
|
65
|
-
token = nonce + timestamp.
|
65
|
+
token = nonce + timestamp.strftime("%Y-%m-%dT%H:%M:%SZ") + expected_password
|
66
66
|
flavors << Base64.encode64(Digest::SHA1.hexdigest(token)).chomp!
|
67
67
|
|
68
68
|
# Java
|
69
|
-
token = Base64.decode64(nonce) + timestamp.
|
69
|
+
token = Base64.decode64(nonce) + timestamp.strftime("%Y-%m-%dT%H:%M:%SZ") + expected_password
|
70
70
|
flavors << Base64.encode64(Digest::SHA1.digest(token)).chomp!
|
71
71
|
|
72
72
|
flavors.each do |f|
|
data/lib/wash_out.rb
CHANGED
@@ -11,6 +11,12 @@ require 'wash_out/model'
|
|
11
11
|
require 'wash_out/wsse'
|
12
12
|
require 'wash_out/middleware'
|
13
13
|
|
14
|
+
module WashOut
|
15
|
+
def self.root
|
16
|
+
File.expand_path '../..', __FILE__
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
14
20
|
module ActionDispatch::Routing
|
15
21
|
class Mapper
|
16
22
|
# Adds the routes for a SOAP endpoint at +controller+.
|