Permalink
Browse files

Merge pull request #416 from r4um/fix_398

Closes #398, Allow and handle nil namespace_identifier.
  • Loading branch information...
2 parents 4f893b0 + d15832e commit 548c836850d9d3b53e1c649caf79307164ee1585 @rubiii rubiii committed Mar 31, 2013
Showing with 17 additions and 2 deletions.
  1. +9 −2 lib/savon/builder.rb
  2. +8 −0 spec/savon/options_spec.rb
View
11 lib/savon/builder.rb
@@ -77,7 +77,12 @@ def namespaces_with_globals
def namespaces
@namespaces ||= begin
namespaces = SCHEMA_TYPES.dup
- namespaces["xmlns:#{namespace_identifier}"] = @globals[:namespace] || @wsdl.namespace
+
+ if namespace_identifier == nil
+ namespaces["xmlns"] = @globals[:namespace] || @wsdl.namespace
+ else
+ namespaces["xmlns:#{namespace_identifier}"] = @globals[:namespace] || @wsdl.namespace
+ end
key = ["xmlns"]
key << env_namespace if env_namespace && env_namespace != ""
@@ -96,7 +101,9 @@ def header
end
def namespaced_message_tag
- if @used_namespaces[[@operation_name.to_s]]
+ if namespace_identifier == nil
+ [message_tag, message_attributes]
+ elsif @used_namespaces[[@operation_name.to_s]]
[@used_namespaces[[@operation_name.to_s]], message_tag, message_attributes]
else
[namespace_identifier, message_tag, message_attributes]
View
8 spec/savon/options_spec.rb
@@ -35,6 +35,14 @@
expect(response.http.body).to include('xmlns:lol="http://v1_0.ws.auth.order.example.com/"')
expect(response.http.body).to include("<lol:authenticate></lol:authenticate>")
end
+
+ it "ignores namespace identifier if it is nil" do
+ client = new_client(:endpoint => @server.url(:repeat), :namespace_identifier => nil)
+ response = client.call(:authenticate, message: {user: 'foo'})
+
+ expect(response.http.body).to include('xmlns="http://v1_0.ws.auth.order.example.com/"')
+ expect(response.http.body).to include("<authenticate><user>foo</user></authenticate>")
+ end
end
context "global :namespaces" do

0 comments on commit 548c836

Please sign in to comment.