Skip to content

Commit

Permalink
Allow and handle nil namespace_identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
r4um committed Mar 22, 2013
1 parent ca971a9 commit d15832e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/savon/builder.rb
Expand Up @@ -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 != ""
Expand All @@ -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]
Expand Down
8 changes: 8 additions & 0 deletions spec/savon/options_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit d15832e

Please sign in to comment.