Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sets the namespace using information from the operation and wsdl namespa... #277

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/savon/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ def extract_options(args)
# Expects an Array of +args+ to preconfigure the system.
def preconfigure(args)
soap.endpoint = wsdl.endpoint
soap.namespace_identifier = args[0]
soap.namespace = wsdl.namespace
soap.element_form_default = wsdl.element_form_default

body = args[2].delete(:body)
Expand All @@ -124,6 +122,18 @@ def preconfigure(args)

soap_action = args[2].delete(:soap_action) || args[1]
set_soap_action soap_action

if wsdl.document? && (operation = wsdl.operations[args[1]]) && operation[:namespace_identifier]
soap.namespace_identifier = operation[:namespace_identifier].to_sym
soap.namespace = wsdl.parser.namespaces[soap.namespace_identifier.to_s]

# Override nil namespace with one specified in WSDL
args[0] = soap.namespace_identifier unless args[0]
else
soap.namespace_identifier = args[0]
soap.namespace = wsdl.namespace
end

set_soap_input *args
end

Expand Down
18 changes: 18 additions & 0 deletions spec/savon/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,24 @@

client.request(:get_user) { soap.namespace = nil }
end

context "when the wsdl's operation namespace identifier matches a document identifier" do
before do
client.wsdl.operations[:authenticate][:namespace_identifier] = "tns"
end

it "sets the soap's namespace identifier to the matching operation's namespace identifier" do
client.request(:authenticate) { soap.namespace_identifier.should == :tns }
end

it "sets the soap's namespace to the namspace matching the identifier" do
client.request(:authenticate) { soap.namespace.should == "http://v1_0.ws.auth.order.example.com/" }
end

it "sets the input tag to result in <tns:authenticate>" do
client.request(:authenticate) { soap.input.should == [:tns, :authenticate, {}] }
end
end
end

context "with a single argument (String)" do
Expand Down