savon 2.2.0 → 2.12.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.travis.yml +20 -9
  4. data/CHANGELOG.md +157 -10
  5. data/CONTRIBUTING.md +1 -1
  6. data/Gemfile +10 -2
  7. data/README.md +38 -13
  8. data/donate.png +0 -0
  9. data/lib/savon/builder.rb +81 -15
  10. data/lib/savon/client.rb +6 -2
  11. data/lib/savon/core_ext/string.rb +0 -1
  12. data/lib/savon/header.rb +68 -17
  13. data/lib/savon/log_message.rb +7 -3
  14. data/lib/savon/message.rb +6 -7
  15. data/lib/savon/mock/expectation.rb +12 -2
  16. data/lib/savon/model.rb +4 -0
  17. data/lib/savon/operation.rb +45 -38
  18. data/lib/savon/options.rb +149 -22
  19. data/lib/savon/qualified_message.rb +31 -25
  20. data/lib/savon/request.rb +24 -4
  21. data/lib/savon/request_logger.rb +48 -0
  22. data/lib/savon/response.rb +35 -18
  23. data/lib/savon/soap_fault.rb +11 -11
  24. data/lib/savon/version.rb +1 -3
  25. data/savon.gemspec +12 -11
  26. data/spec/fixtures/response/empty_soap_fault.xml +13 -0
  27. data/spec/fixtures/response/f5.xml +39 -0
  28. data/spec/fixtures/response/no_body.xml +1 -0
  29. data/spec/fixtures/response/soap_fault_funky.xml +8 -0
  30. data/spec/fixtures/wsdl/brand.xml +624 -0
  31. data/spec/fixtures/wsdl/elements_in_types.xml +43 -0
  32. data/spec/fixtures/wsdl/no_message_tag.xml +1267 -0
  33. data/spec/fixtures/wsdl/vies.xml +176 -0
  34. data/spec/integration/centra_spec.rb +67 -0
  35. data/spec/integration/email_example_spec.rb +1 -1
  36. data/spec/integration/random_quote_spec.rb +23 -0
  37. data/spec/integration/stockquote_example_spec.rb +7 -1
  38. data/spec/integration/support/application.rb +1 -1
  39. data/spec/integration/zipcode_example_spec.rb +1 -1
  40. data/spec/savon/builder_spec.rb +50 -0
  41. data/spec/savon/client_spec.rb +78 -0
  42. data/spec/savon/core_ext/string_spec.rb +9 -9
  43. data/spec/savon/features/message_tag_spec.rb +5 -0
  44. data/spec/savon/http_error_spec.rb +2 -2
  45. data/spec/savon/log_message_spec.rb +18 -1
  46. data/spec/savon/message_spec.rb +70 -0
  47. data/spec/savon/mock_spec.rb +31 -0
  48. data/spec/savon/model_spec.rb +28 -0
  49. data/spec/savon/operation_spec.rb +69 -3
  50. data/spec/savon/options_spec.rb +515 -87
  51. data/spec/savon/qualified_message_spec.rb +101 -0
  52. data/spec/savon/request_logger_spec.rb +37 -0
  53. data/spec/savon/request_spec.rb +85 -10
  54. data/spec/savon/response_spec.rb +118 -27
  55. data/spec/savon/soap_fault_spec.rb +25 -5
  56. data/spec/savon/softlayer_spec.rb +27 -0
  57. data/spec/spec_helper.rb +5 -2
  58. data/spec/support/adapters.rb +48 -0
  59. data/spec/support/integration.rb +1 -1
  60. metadata +76 -93
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: adc5b65f9ac22024b164dae28b0198a4269b97ab14afac694b946e7cef896d7e
4
+ data.tar.gz: 13138a12de62757d551a9114b2741501accbbad169a2a00a9dee7f439ad48a78
5
+ SHA512:
6
+ metadata.gz: 11e3b779fc0376993c46d6ab595e96896a5b0a7ea6f478d3ce93918ebfbd93ff14c4c5ac44c0080ce527c4e30e8615d559b373900acf35b96d2d67b1661b0f28
7
+ data.tar.gz: 0a8b5bcacf019b33eaafee305aee4f33c1733c26455d446738c28ad14567d69288c0f1cc0226f2e9c5304687a5b49a7011397465c16350b03b31370626014292
data/.gitignore CHANGED
@@ -2,6 +2,7 @@
2
2
  .DS_Store
3
3
  .yardoc
4
4
  doc
5
+ rdox
5
6
  coverage
6
7
  tmp
7
8
  *.rbc
@@ -10,3 +11,4 @@ tmp
10
11
  .bundle
11
12
  .rspec
12
13
  Gemfile.lock
14
+ bin/
@@ -1,15 +1,26 @@
1
1
  # https://github.com/travis-ci/travis-ci/wiki/.travis.yml-options
2
2
  language: "ruby"
3
+
3
4
  script: "bundle exec rake --trace"
5
+
4
6
  rvm:
5
- - 1.8.7
6
- - 1.9.2
7
- - 1.9.3
8
- - 2.0
9
- - jruby-18mode
10
- - jruby-19mode
11
- - rbx-18mode
12
- - rbx-19mode
13
- - ree
7
+ - "2.5"
8
+ - "2.6"
9
+ - "2.7"
10
+
11
+ matrix:
12
+ include:
13
+ - name: "JRuby 9.2"
14
+ rvm: jruby-9.2.12.0
15
+ jdk: openjdk11
16
+ env: JAVA_OPTS="--add-opens java.base/java.security.cert=ALL-UNNAMED --add-opens java.base/java.security=ALL-UNNAMED"
17
+ - name: Rubinius
18
+ rvm: rbx-4
19
+ dist: trusty
20
+ allow_failures:
21
+ - name: Rubinius
22
+ - name: "JRuby 9.2"
23
+ fast_finish: true
24
+
14
25
  notifications:
15
26
  irc: "irc.freenode.org#savon"
@@ -1,3 +1,150 @@
1
+
2
+ ## 2.12.1 (2020-07-05)
3
+
4
+ * Fix: [#917](https://github.com/savonrb/savon/pull/917) elementFormDefault="qualified" regression
5
+ * Fix: [#875](https://github.com/savonrb/savon/pull/875) Fix detecting Soap 1.1 Fault when faultcode and faultstring are empty
6
+
7
+ # 2.12.0 (2018-01-16)
8
+
9
+ * Drop support for ruby 2.1 and below.
10
+ * Fix: [#822](https://github.com/savonrb/savon/pull/822) Raise correct error when SOAP envelope only contains a string
11
+ * Fix: [#833](https://github.com/savonrb/savon/pull/833) Fixes boolean handling regression introduced in 2.11.2
12
+ * Feature: [#794](https://github.com/savonrb/savon/pull/794), add global option ssl_ciphers.
13
+ * Feature: [#753](https://github.com/savonrb/savon/pull/753) Add headers configuration to WSDLRequest#build
14
+ * Feature: [#812](https://github.com/savonrb/savon/pull/812) Allow `proxy` option to be `nil`.
15
+ * Feature: [#838](https://github.com/savonrb/savon/pull/838) Added ssl_ca_path and ssl_cert_store to globals
16
+
17
+ # 2.11.2 (2017-08-03)
18
+ * Fix: [#676](https://github.com/savonrb/savon/pull/676) Fixes handling of `content!` and `attributes!`
19
+ * Fix: [#800](https://github.com/savonrb/savon/pull/800) Fix exception calling `SOAPFault#to_s` when http.body is empty
20
+ * Fix: [#757](https://github.com/savonrb/savon/pull/757) Logging: Use filter without automatic pretty printing
21
+ * Fix: [#771](https://github.com/savonrb/savon/pull/771) Restore support for cookies when using custom headers
22
+ * Feature: [#744](https://github.com/savonrb/savon/pull/744) Add support for rpc encoded wsdl
23
+ * Feature: [#742](https://github.com/savonrb/savon/pull/742) Add support for local request headers
24
+ * Feature: [#704](https://github.com/savonrb/savon/pull/704) Add possibility to pass attribute delete_namespace_attributes to Nori
25
+
26
+ # 2.11.1 (2015-05-27)
27
+
28
+ * Replace dependency on [uuid](https://rubygems.org/gems/uuid), using SecureRandom.uuid instead.
29
+
30
+ # 2.11.0 (2015-03-31)
31
+
32
+ * Formally drop support for 1.8.7.
33
+
34
+ # 2.10.1 (2015-03-15)
35
+
36
+ * Feature: [#673](https://github.com/savonrb/savon/pull/673) Adds an :unwrap option that is passed to Gyoku.
37
+
38
+ # 2.10.0 (2015-03-02)
39
+
40
+ * Fix: This reverts a purported "fix" to operation names.
41
+
42
+ # 2.9.0 (2015-01-29)
43
+
44
+ * Feature: [#655] Wasabi exceptions should be rethrown as Savon errors. This should make it easier to catch errors thrown by Savon::Client.
45
+ * Feature: [#630] ServiceFaults are correctly identified as Soap Faults.
46
+
47
+ # 2.8.0 (2014-11-12)
48
+
49
+ * Feature : [#620](https://github.com/savonrb/savon/pull/620) add #build_request method that builds the actual XML request body, but does not submit it. Useful for debugging, possibly.
50
+ * Fix : Loosened dependencies on Gyoku, Nori, Akami, and other Savon-dependency gems
51
+ * Feature: [#636](https://github.com/savonrb/savon/pull/636) Set HTTPI.logger when Savon's logger is configured.
52
+ * Feature: [#639](https://github.com/savonrb/savon/issues/639) Allow setting any SSL version that OpenSSL provides. See [the relevant HTTPI issue](https://github.com/savonrb/httpi/pull/136) for more information.
53
+
54
+ # 2.7.2 (2014-09-23)
55
+
56
+ Fix : Preserve false values (https://github.com/savonrb/savon/issues/321)
57
+
58
+ # 2.7.1 (2014-09-23)
59
+
60
+ * Fix : Fix a crash in builder when request headers do not contain WSA headers
61
+
62
+ # 2.7.0 (2014-09-23)
63
+
64
+ * Feature: Signing requests. Added wsse_signature.
65
+ ```ruby
66
+ client = Savon.client(wsdl: 'http://service.example.com?wsdl') do
67
+ wsse_signature Akami::WSSE::Signature.new(Akami::WSSE::Certs.new(:cert_file => 'c.pem', :private_key_file => 'p.pem'))
68
+ end
69
+ ```
70
+
71
+ # 2.5.0 (2014-05-03)
72
+
73
+ * Feature: [#573](https://github.com/savonrb/savon/pull/573) Add an `all_operations` method to `Savon::Model` that automatically adds all available operations to the model.
74
+
75
+ * Feature: [#566](https://github.com/savonrb/savon/pull/566) Allow specifying HTTPI adapter per client.
76
+
77
+ ```ruby
78
+ curb_client = Savon.client(wsdl: "http://example.com/service.wsdl", adapter: :curb)
79
+
80
+ http_client = Savon.client(wsdl: "http://example.com/service.wsdl", adapter: :httpclient)
81
+ ```
82
+
83
+ ## 2.4.0 (2014-03-31)
84
+
85
+ * Logging is off by default. To enable this behavior, set the :log option to true
86
+
87
+ ``` ruby
88
+ client = Savon.client(wsdl: "http://example.com/service.wsdl", log: true)
89
+ ```
90
+
91
+ ### 2.3.2 (2013-12-09)
92
+
93
+ * Fix: [#520](https://github.com/savonrb/savon/issues/520) Fixes a regression in message tags in requests and responses.
94
+
95
+ ### 2.3.1 (2013-12-05)
96
+
97
+ * Removed dependency on Nokogiri <= 1.4 -- This improves support for ruby 1.9.3 and 2.0.0 and officially begins the end of support for ruby 1.8.7
98
+ See [issue #487](https://github.com/savonrb/savon/issues/487)
99
+
100
+ ### 2.3.0 (2013-07-27)
101
+
102
+ Combined release ticket: [#481](https://github.com/savonrb/savon/issues/481)
103
+
104
+ * Feature: [#405](https://github.com/savonrb/savon/issues/405) Improved NTLM support based on HTTPI v2.1.0.
105
+
106
+ * Feature: [#424](https://github.com/savonrb/savon/issues/424) Adds support for multipart responses
107
+ through the updated [savon-multipart](https://github.com/savonrb/savon-multipart) gem. You can now
108
+ specify `multipart: true` either as a global or local option. Please make sure you have the
109
+ updated `savon-multipart` gem installed and loaded, as it is not a direct dependency of Savon.
110
+
111
+ ``` ruby
112
+ require 'savon'
113
+ require 'savon-multipart'
114
+
115
+ # expect multipart responses for every operation
116
+ client = Savon.client(wsdl: wsdl, multipart: true)
117
+
118
+ # only expect a multipart response for this operation
119
+ client.call(:my_operation, multipart: true)
120
+ ```
121
+
122
+ * Feature: [#470](https://github.com/savonrb/savon/issues/470) Added a local `:soap_header` option
123
+ to allow setting the SOAP header per request.
124
+
125
+ * Feature: [#402](https://github.com/savonrb/savon/issues/402) Makes it possible to create mocks
126
+ that don't care about the message sent by using `:any` for the `:message` option.
127
+
128
+ ``` ruby
129
+ savon.expects(:authenticate).with(message: :any)
130
+ ```
131
+
132
+ * Fix: [#450](https://github.com/savonrb/savon/pull/450) Added `Savon::Response#soap_fault`
133
+ and `Savon::Response#http_error` which were present in version 1.
134
+
135
+ * Fix: [#474](https://github.com/savonrb/savon/issues/474) Changed `Savon::Response#header` and
136
+ `Savon::Response#body` to respect the global `:convert_response_tags_to` and `:strip_namespaces`
137
+ options and return the expected result instead of raising a `Savon::InvalidResponseError`.
138
+
139
+ * Fix: [#461](https://github.com/savonrb/savon/issues/461) Fixed two problems related to namespace
140
+ qualified messages and the element `:order!`.
141
+
142
+ * Fix: [#476](https://github.com/savonrb/savon/issues/476) fixes a problem where the namespace
143
+ for the message tag was not correctly determined from the WSDL.
144
+
145
+ * Fix: [#468](https://github.com/savonrb/savon/issues/468) Changed the dependency on Nokogiri
146
+ to < 1.6, because Nokogiri 1.6 dropped support for Ruby 1.8.
147
+
1
148
  ### 2.2.0 (2013-04-21)
2
149
 
3
150
  * Feature: [#416](https://github.com/savonrb/savon/pull/416) The global `namespace_identifier`
@@ -10,14 +157,14 @@
10
157
  This is because regardless of whether you're using the Hash or block syntax to pass global
11
158
  or local options, both are just method calls on some options object.
12
159
 
13
- ```
160
+ ``` ruby
14
161
  NoMethodError: undefined method 'wsdk' for #<Savon::GlobalOptions:0x007fed95a55228>
15
162
  ```
16
163
 
17
164
  As of this change, Savon now catches those errors and raise a `Savon::UnknownOptionError`
18
165
  with a slightly more helpful error message instead.
19
166
 
20
- ```
167
+ ``` ruby
21
168
  Savon::UnknownOptionError:
22
169
  Unknown global option: :wsdk
23
170
  ```
@@ -192,10 +339,10 @@
192
339
  in the document:
193
340
 
194
341
  ``` xml
195
- <env:Envelope
196
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
197
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
198
- xmlns:tns="http://v1_0.ws.auth.order.example.com/"
342
+ <env:Envelope
343
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
344
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
345
+ xmlns:tns="http://v1_0.ws.auth.order.example.com/"
199
346
  xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
200
347
 
201
348
  <tns:authenticate>
@@ -213,7 +360,7 @@
213
360
  The global config is cloned when a new client is initialized and gets used instead of the global one.
214
361
  In addition, for `Savon::Model` classes, the config is cloned per class.
215
362
 
216
- Closes [#84](https://github.com/savonrb/savon/issues/84) by allowing one logger per client and
363
+ Closes [#84](https://github.com/savonrb/savon/issues/84) by allowing one logger per client and
217
364
  [#270](https://github.com/savonrb/savon/issues/270) by allowing to specify error handling per client.
218
365
 
219
366
  * Feature: Added an option to pretty print XML in log messages. Closes [#256](https://github.com/savonrb/savon/issues/256)
@@ -903,7 +1050,7 @@ Pay attention to the following list and read the updated Wiki: http://wiki.githu
903
1050
 
904
1051
  ```
905
1052
  Benchmarks (1000 SOAP calls):
906
-
1053
+
907
1054
  user system total real
908
1055
  0.6.4 72.180000 8.280000 80.460000 (750.799011)
909
1056
  0.6.3 192.900000 19.630000 212.530000 (914.031865)
@@ -917,7 +1064,7 @@ Pay attention to the following list and read the updated Wiki: http://wiki.githu
917
1064
 
918
1065
  ```
919
1066
  Benchmarks (1000 SOAP calls):
920
-
1067
+
921
1068
  user system total real
922
1069
  WSDL 192.900000 19.630000 212.530000 (914.031865)
923
1070
  disabled WSDL 5.680000 1.340000 7.020000 (298.265318)
@@ -927,7 +1074,7 @@ Pay attention to the following list and read the updated Wiki: http://wiki.githu
927
1074
 
928
1075
  ```
929
1076
  Benchmarks (1000 SOAP calls):
930
-
1077
+
931
1078
  user system total real
932
1079
  0.6.3 192.900000 19.630000 212.530000 (914.031865)
933
1080
  0.6.2 574.720000 78.380000 653.100000 (1387.778539)
@@ -14,7 +14,7 @@ problems and make sure they don't come back.
14
14
 
15
15
  So if you can reproduce your problem in a spec, that would be awesome! If you can't, please
16
16
  let us know how we could make this easier for you. Also, provide code and the WSDL of the
17
- service your working with so others can try to come up with a spec for your problem.
17
+ service you're working with so others can try to come up with a spec for your problem.
18
18
 
19
19
  After we have a failing spec, it obviously needs to be fixed. Make sure your new spec is the
20
20
  only failing one under the `spec` directory. Travis only runs the "unit tests" at `spec/savon`,
data/Gemfile CHANGED
@@ -1,5 +1,13 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
- gem "httpclient", "~> 2.3.0"
5
- gem "simplecov", :require => false, :group => :test
4
+ gem "httpclient", "~> 2.7.1"
5
+
6
+ gem "simplecov", :require => false
7
+ gem "coveralls", :require => false
8
+
9
+ platform :rbx do
10
+ gem 'racc'
11
+ gem 'rubysl'
12
+ gem 'rubinius-coverage'
13
+ end
data/README.md CHANGED
@@ -5,14 +5,15 @@ Heavy metal SOAP client
5
5
  [Documentation](http://savonrb.com) | [RDoc](http://rubydoc.info/gems/savon) |
6
6
  [Mailing list](https://groups.google.com/forum/#!forum/savonrb) | [Twitter](http://twitter.com/savonrb)
7
7
 
8
- [![Build Status](https://secure.travis-ci.org/savonrb/savon.png)](http://travis-ci.org/savonrb/savon)
9
- [![Gem Version](https://badge.fury.io/rb/savon.png)](http://badge.fury.io/rb/savon)
10
- [![Code Climate](https://codeclimate.com/github/savonrb/savon.png)](https://codeclimate.com/github/savonrb/savon)
8
+ [![Build Status](https://secure.travis-ci.org/savonrb/savon.svg?branch=master)](http://travis-ci.org/savonrb/savon)
9
+ [![Gem Version](https://badge.fury.io/rb/savon.svg)](http://badge.fury.io/rb/savon)
10
+ [![Code Climate](https://codeclimate.com/github/savonrb/savon.svg)](https://codeclimate.com/github/savonrb/savon)
11
+ [![Coverage Status](https://coveralls.io/repos/savonrb/savon/badge.svg?branch=version2)](https://coveralls.io/r/savonrb/savon)
11
12
 
12
13
 
13
- ## Installation
14
+ ## Version 2
14
15
 
15
- Savon is available through [Rubygems](http://rubygems.org/gems/savon) and can be installed via:
16
+ Savon version 2 is available through [Rubygems](http://rubygems.org/gems/savon) and can be installed via:
16
17
 
17
18
  ```
18
19
  $ gem install savon
@@ -21,10 +22,9 @@ $ gem install savon
21
22
  or add it to your Gemfile like this:
22
23
 
23
24
  ```
24
- gem 'savon', '~> 2.1.0'
25
+ gem 'savon', '~> 2.12.0'
25
26
  ```
26
27
 
27
-
28
28
  ## Usage example
29
29
 
30
30
  ``` ruby
@@ -43,15 +43,40 @@ response.body
43
43
  # => { find_user_response: { id: 42, name: 'Hoff' } }
44
44
  ```
45
45
 
46
- For more examples, you should check out the [integration tests](https://github.com/savonrb/savon/tree/master/spec/integration).
46
+ For more examples, you should check out the
47
+ [integration tests](https://github.com/savonrb/savon/tree/version2/spec/integration).
47
48
 
49
+ ## Ruby version support
50
+ * 2.12.x - MRI 2.2, 2.3, 2.4
51
+ * 2.11.x - MRI 2.0, 2.1, 2.2, and 2.3
48
52
 
49
- ## Documentation
53
+ If you are running MRI 1.8.7, try the 2.6.x branch.
54
+
55
+ ## Running tests
56
+
57
+ ```bash
58
+ $ bundle install
59
+ $ bundle exec rspec
60
+ ```
61
+
62
+ ## FAQ
63
+
64
+ * URI::InvalidURIError -- if you see this error, then it is likely that the http client you are using cannot parse the URI for your WSDL. Try `gem install httpclient` or add it to your `Gemfile`.
65
+ - See https://github.com/savonrb/savon/issues/488 for more info
50
66
 
51
- Please make sure to read the documentation for your version:
67
+ ## Give back
52
68
 
53
- * [Version 2](http://savonrb.com/version2.html)
54
- * [Version 1](http://savonrb.com)
69
+ If you're using Savon and you or your company is making money from it, then please consider
70
+ donating via [Gittip](https://www.gittip.com/tjarratt/) so that I can continue to improve it.
55
71
 
56
- And if you find any problems with it or if you think something's missing,
72
+ [![donate](donate.png)](https://www.gittip.com/tjarratt/)
73
+
74
+
75
+ ## Documentation
76
+
77
+ Please make sure to [read the documentation](http://savonrb.com/version2/).
78
+
79
+ And if you find any problems with it or if you think something's missing,
57
80
  feel free to [help out and improve the documentation](https://github.com/savonrb/savonrb.com).
81
+
82
+ Donate icon from the [Noun Project](http://thenounproject.com/noun/donate/#icon-No285).
Binary file
@@ -17,12 +17,15 @@ module Savon
17
17
  2 => "http://www.w3.org/2003/05/soap-envelope"
18
18
  }
19
19
 
20
+ WSA_NAMESPACE = "http://www.w3.org/2005/08/addressing"
21
+
20
22
  def initialize(operation_name, wsdl, globals, locals)
21
23
  @operation_name = operation_name
22
24
 
23
- @wsdl = wsdl
24
- @globals = globals
25
- @locals = locals
25
+ @wsdl = wsdl
26
+ @globals = globals
27
+ @locals = locals
28
+ @signature = @locals[:wsse_signature] || @globals[:wsse_signature]
26
29
 
27
30
  @types = convert_type_definitions_to_hash
28
31
  @used_namespaces = convert_type_namespaces_to_hash
@@ -32,13 +35,49 @@ module Savon
32
35
  Nokogiri.XML(to_s).to_xml(:indent => 2)
33
36
  end
34
37
 
35
- def to_s
36
- return @locals[:xml] if @locals.include? :xml
38
+ def build_document
39
+ xml_result = tag(builder, :Envelope, namespaces_with_globals) do |xml|
40
+ tag(xml, :Header, header_attributes) { xml << header.to_s } unless header.empty?
41
+ if @globals[:no_message_tag]
42
+ tag(xml, :Body, body_attributes) { xml << message.to_s }
43
+ else
44
+ tag(xml, :Body, body_attributes) { xml.tag!(*namespaced_message_tag) { xml << body_message } }
45
+ end
46
+ end
37
47
 
38
- tag(builder, :Envelope, namespaces_with_globals) do |xml|
39
- tag(xml, :Header) { xml << header.to_s } unless header.empty?
40
- tag(xml, :Body) { xml.tag!(*namespaced_message_tag) { xml << message.to_s } }
48
+ # if we have a signature sign the document
49
+ if @signature
50
+ @signature.document = xml_result
51
+
52
+ 2.times do
53
+ @header = nil
54
+ @signature.document = tag(builder, :Envelope, namespaces_with_globals) do |xml|
55
+ tag(xml, :Header, header_attributes) { xml << header.to_s } unless header.empty?
56
+ if @globals[:no_message_tag]
57
+ tag(xml, :Body, body_attributes) { xml << message.to_s }
58
+ else
59
+ tag(xml, :Body, body_attributes) { xml.tag!(*namespaced_message_tag) { xml << message.to_s } }
60
+ end
61
+ end
62
+ end
63
+
64
+ xml_result = @signature.document
41
65
  end
66
+
67
+ xml_result
68
+ end
69
+
70
+ def header_attributes
71
+ @globals[:use_wsa_headers] ? { 'xmlns:wsa' => WSA_NAMESPACE } : {}
72
+ end
73
+
74
+ def body_attributes
75
+ @body_attributes ||= @signature.nil? ? {} : @signature.body_attributes
76
+ end
77
+
78
+ def to_s
79
+ return @locals[:xml] if @locals.include? :xml
80
+ build_document
42
81
  end
43
82
 
44
83
  private
@@ -101,17 +140,36 @@ module Savon
101
140
  end
102
141
 
103
142
  def namespaced_message_tag
143
+ tag_name = message_tag
144
+ return [tag_name] if @wsdl.document? and @wsdl.soap_input(@operation_name.to_sym).is_a?(Hash)
104
145
  if namespace_identifier == nil
105
- [message_tag, message_attributes]
106
- elsif @used_namespaces[[@operation_name.to_s]]
107
- [@used_namespaces[[@operation_name.to_s]], message_tag, message_attributes]
146
+ [tag_name, message_attributes]
147
+ elsif @used_namespaces[[tag_name.to_s]]
148
+ [@used_namespaces[[tag_name.to_s]], tag_name, message_attributes]
108
149
  else
109
- [namespace_identifier, message_tag, message_attributes]
150
+ [namespace_identifier, tag_name, message_attributes]
110
151
  end
111
152
  end
112
153
 
154
+ def serialized_message_tag
155
+ [:wsdl, @wsdl.soap_input(@operation_name.to_sym).keys.first, {}]
156
+ end
157
+
158
+ def serialized_messages
159
+ messages = ""
160
+ message_tag = serialized_message_tag[1]
161
+ @wsdl.soap_input(@operation_name.to_sym)[message_tag].each_pair do |message, type|
162
+ break if @locals[:message].nil?
163
+ message_locals = @locals[:message][message.snakecase.to_sym]
164
+ message_content = Message.new(message_tag, namespace_identifier, @types, @used_namespaces, message_locals, :unqualified, @globals[:convert_request_keys_to], @globals[:unwrap]).to_s
165
+ messages << "<#{message} xsi:type=\"#{type.join(':')}\">#{message_content}</#{message}>"
166
+ end
167
+ messages
168
+ end
169
+
113
170
  def message_tag
114
- message_tag = @locals[:message_tag]
171
+ message_tag = @wsdl.soap_input(@operation_name.to_sym).keys.first if @wsdl.document? and @wsdl.soap_input(@operation_name.to_sym).is_a?(Hash)
172
+ message_tag ||= @locals[:message_tag]
115
173
  message_tag ||= @wsdl.soap_input(@operation_name.to_sym) if @wsdl.document?
116
174
  message_tag ||= Gyoku.xml_tag(@operation_name, :key_converter => @globals[:convert_request_keys_to])
117
175
 
@@ -122,11 +180,19 @@ module Savon
122
180
  @locals[:attributes] || {}
123
181
  end
124
182
 
183
+ def body_message
184
+ if @wsdl.document? and @wsdl.soap_input(@operation_name.to_sym).is_a?(Hash)
185
+ serialized_messages
186
+ else
187
+ message.to_s
188
+ end
189
+ end
190
+
125
191
  def message
126
192
  element_form_default = @globals[:element_form_default] || @wsdl.element_form_default
127
193
  # TODO: clean this up! [dh, 2012-12-17]
128
- Message.new(@operation_name, namespace_identifier, @types, @used_namespaces, @locals[:message],
129
- element_form_default, @globals[:convert_request_keys_to])
194
+ Message.new(message_tag, namespace_identifier, @types, @used_namespaces, @locals[:message],
195
+ element_form_default, @globals[:convert_request_keys_to], @globals[:unwrap])
130
196
  end
131
197
 
132
198
  def namespace_identifier