Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implemented conditional adding of the WSA elements, according to the …

…WSA spec.
  • Loading branch information...
commit fb54bf95058b6c18ecea2460bb3c7d289db29f3e 1 parent 25c78b9
@redbar0n authored
Showing with 8 additions and 3 deletions.
  1. +8 −3 lib/savon/wsa.rb
View
11 lib/savon/wsa.rb
@@ -28,11 +28,12 @@ def []=(key, value)
attr_accessor :action, :message_id, :reply_to, :to
+ ## The WSA specification dictates these rules, see §3.1 at http://www.w3.org/Submission/ws-addressing/
def ws_addressing?
ret_val = false
if (action && to)
ret_val = true
- if reply_to && !message_id
+ if (reply_to && !message_id)
ret_val = false
end
end
@@ -47,9 +48,13 @@ def to_xml
if ws_addressing?
xml += Gyoku.xml wsa_element("Action", action).merge!(hash)
- xml += Gyoku.xml wsa_element("MessageID", message_id).merge!(hash)
- xml += Gyoku.xml wsa_element("ReplyTo", reply_to, "Address").merge!(hash)
xml += Gyoku.xml wsa_element("To", to).merge!(hash)
+ if reply_to
+ xml += Gyoku.xml wsa_element("ReplyTo", reply_to, "Address").merge!(hash)
+ xml += Gyoku.xml wsa_element("MessageID", message_id).merge!(hash) # must be present when reply_to is present, see the WSA spec
+ elsif message_id
+ xml += Gyoku.xml wsa_element("MessageID", message_id).merge!(hash)
+ end
end
xml + @other_xml
Please sign in to comment.
Something went wrong with that request. Please try again.