Permalink
Browse files

Allow and handle nil namespace_identifier

  • Loading branch information...
r4um committed Mar 22, 2013
1 parent ca971a9 commit d15832eddda3896a501d8fbdec13505a0c07b431
Showing with 17 additions and 2 deletions.
  1. +9 −2 lib/savon/builder.rb
  2. +8 −0 spec/savon/options_spec.rb
View
@@ -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]
@@ -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 d15832e

Please sign in to comment.