diff --git a/lib/savon/builder.rb b/lib/savon/builder.rb
index 770949aa..253f4996 100644
--- a/lib/savon/builder.rb
+++ b/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]
diff --git a/spec/savon/options_spec.rb b/spec/savon/options_spec.rb
index 0a80841d..d902ce6a 100644
--- a/spec/savon/options_spec.rb
+++ b/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("")
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("foo")
+ end
end
context "global :namespaces" do