Skip to content
This repository
Browse code

Merge pull request #416 from r4um/fix_398

Closes #398, Allow and handle nil namespace_identifier.
  • Loading branch information...
commit 548c836850d9d3b53e1c649caf79307164ee1585 2 parents 4f893b0 + d15832e
Daniel Harrington rubiii authored

Showing 2 changed files with 17 additions and 2 deletions. Show diff stats Hide diff stats

  1. +9 2 lib/savon/builder.rb
  2. +8 0 spec/savon/options_spec.rb
11 lib/savon/builder.rb
@@ -77,7 +77,12 @@ def namespaces_with_globals
77 77 def namespaces
78 78 @namespaces ||= begin
79 79 namespaces = SCHEMA_TYPES.dup
80   - namespaces["xmlns:#{namespace_identifier}"] = @globals[:namespace] || @wsdl.namespace
  80 +
  81 + if namespace_identifier == nil
  82 + namespaces["xmlns"] = @globals[:namespace] || @wsdl.namespace
  83 + else
  84 + namespaces["xmlns:#{namespace_identifier}"] = @globals[:namespace] || @wsdl.namespace
  85 + end
81 86
82 87 key = ["xmlns"]
83 88 key << env_namespace if env_namespace && env_namespace != ""
@@ -96,7 +101,9 @@ def header
96 101 end
97 102
98 103 def namespaced_message_tag
99   - if @used_namespaces[[@operation_name.to_s]]
  104 + if namespace_identifier == nil
  105 + [message_tag, message_attributes]
  106 + elsif @used_namespaces[[@operation_name.to_s]]
100 107 [@used_namespaces[[@operation_name.to_s]], message_tag, message_attributes]
101 108 else
102 109 [namespace_identifier, message_tag, message_attributes]
8 spec/savon/options_spec.rb
@@ -35,6 +35,14 @@
35 35 expect(response.http.body).to include('xmlns:lol="http://v1_0.ws.auth.order.example.com/"')
36 36 expect(response.http.body).to include("<lol:authenticate></lol:authenticate>")
37 37 end
  38 +
  39 + it "ignores namespace identifier if it is nil" do
  40 + client = new_client(:endpoint => @server.url(:repeat), :namespace_identifier => nil)
  41 + response = client.call(:authenticate, message: {user: 'foo'})
  42 +
  43 + expect(response.http.body).to include('xmlns="http://v1_0.ws.auth.order.example.com/"')
  44 + expect(response.http.body).to include("<authenticate><user>foo</user></authenticate>")
  45 + end
38 46 end
39 47
40 48 context "global :namespaces" do

0 comments on commit 548c836

Please sign in to comment.
Something went wrong with that request. Please try again.