File tree Expand file tree Collapse file tree 5 files changed +41
-6
lines changed Expand file tree Collapse file tree 5 files changed +41
-6
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ gem "httpclient", "~> 2.3.4"
5
5
6
6
gem "simplecov" , :require => false
7
7
gem "coveralls" , :require => false
8
+ gem "uuid"
8
9
9
10
platform :rbx do
10
11
gem 'json'
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ class Builder
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
@@ -32,15 +34,25 @@ def pretty
32
34
Nokogiri . XML ( to_s ) . to_xml ( :indent => 2 )
33
35
end
34
36
35
- def to_s
36
- return @locals [ :xml ] if @locals . include? :xml
37
-
37
+ def build_document
38
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 } }
39
+ tag ( xml , :Header , header_attributes ) { xml << header . to_s } unless header . empty?
40
+ tag ( xml , :Body , body_attributes ) { xml . tag! ( *namespaced_message_tag ) { xml << message . to_s } }
41
41
end
42
42
end
43
43
44
+ def header_attributes
45
+ { 'xmlns:wsa' => WSA_NAMESPACE } if @globals [ :use_wsa_headers ]
46
+ end
47
+
48
+ def body_attributes
49
+ end
50
+
51
+ def to_s
52
+ return @locals [ :xml ] if @locals . include? :xml
53
+ build_document
54
+ end
55
+
44
56
private
45
57
46
58
def convert_type_definitions_to_hash
Original file line number Diff line number Diff line change 1
1
require "akami"
2
2
require "gyoku"
3
+ require "uuid"
3
4
4
5
module Savon
5
6
class Header
@@ -13,6 +14,9 @@ def initialize(globals, locals)
13
14
@global_header = globals [ :soap_header ]
14
15
@local_header = locals [ :soap_header ]
15
16
17
+ @globals = globals
18
+ @locals = locals
19
+
16
20
@header = build
17
21
end
18
22
@@ -30,7 +34,7 @@ def to_s
30
34
private
31
35
32
36
def build
33
- build_header + build_wsse_header
37
+ build_header + build_wsa_header + build_wsse_header
34
38
end
35
39
36
40
def build_header
@@ -51,6 +55,15 @@ def build_wsse_header
51
55
wsse_header . respond_to? ( :to_xml ) ? wsse_header . to_xml : ""
52
56
end
53
57
58
+ def build_wsa_header
59
+ return '' unless @globals [ :use_wsa_headers ]
60
+ convert_to_xml ( {
61
+ 'wsa:Action' => @locals [ :soap_action ] ,
62
+ 'wsa:To' => @globals [ :endpoint ] ,
63
+ 'wsa:MessageID' => "urn:uuid:#{ UUID . new . generate } "
64
+ } )
65
+ end
66
+
54
67
def convert_to_xml ( hash_or_string )
55
68
if hash_or_string . kind_of? Hash
56
69
Gyoku . xml ( hash_or_string , gyoku_options )
Original file line number Diff line number Diff line change @@ -87,6 +87,9 @@ def call_with_logging(request)
87
87
end
88
88
89
89
def build_request ( builder )
90
+ @locals [ :soap_action ] ||= soap_action
91
+ @globals [ :endpoint ] ||= endpoint
92
+
90
93
request = SOAPRequest . new ( @globals ) . build (
91
94
:soap_action => soap_action ,
92
95
:cookies => @locals [ :cookies ]
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ def initialize(options = {})
57
57
:convert_attributes_to => lambda { |k , v | [ k , v ] } ,
58
58
:multipart => false ,
59
59
:adapter => nil ,
60
+ :use_wsa_headers => false ,
60
61
}
61
62
62
63
options = defaults . merge ( options )
@@ -271,6 +272,11 @@ def multipart(multipart)
271
272
def adapter ( adapter )
272
273
@options [ :adapter ] = adapter
273
274
end
275
+
276
+ # Enable inclusion of WS-Addressing headers.
277
+ def use_wsa_headers ( use )
278
+ @options [ :use_wsa_headers ] = use
279
+ end
274
280
end
275
281
276
282
class LocalOptions < Options
You can’t perform that action at this time.
0 commit comments