From 15ec522d0cb754b1d6423ab782d0f90e1ef3c91c Mon Sep 17 00:00:00 2001 From: Lukas Oberhuber Date: Mon, 6 Jul 2020 00:21:23 +0100 Subject: [PATCH] Fix elementFormDefault="qualified" regression (#917) Types were not properly qualified This test is based on a simplified real world wsdl --- lib/savon/qualified_message.rb | 2 +- spec/fixtures/wsdl/elements_in_types.xml | 43 ++++++++++++++++++++++++ spec/savon/options_spec.rb | 11 ++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 spec/fixtures/wsdl/elements_in_types.xml diff --git a/lib/savon/qualified_message.rb b/lib/savon/qualified_message.rb index b93b88c8..6e6523b6 100644 --- a/lib/savon/qualified_message.rb +++ b/lib/savon/qualified_message.rb @@ -26,7 +26,7 @@ def to_hash(hash, path) translated_key = translate_tag(key) newkey = add_namespaces_to_values(key, path).first newpath = path + [translated_key] - newhash[newkey] = to_hash(value, newpath) + newhash[newkey] = to_hash(value, @types[newpath] ? [@types[newpath]] : newpath) end end newhash diff --git a/spec/fixtures/wsdl/elements_in_types.xml b/spec/fixtures/wsdl/elements_in_types.xml new file mode 100644 index 00000000..9e9071d3 --- /dev/null +++ b/spec/fixtures/wsdl/elements_in_types.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TopLevelTransaction. + + + + + + + + + + + + + diff --git a/spec/savon/options_spec.rb b/spec/savon/options_spec.rb index 28c78385..155b8c94 100644 --- a/spec/savon/options_spec.rb +++ b/spec/savon/options_spec.rb @@ -219,6 +219,17 @@ def to_s expect(response.http.body).to include("lea") expect(response.http.body).to include("top-secret") end + + it "qualifies elements embedded in complex types" do + client = new_client(:endpoint => @server.url(:repeat), + :wsdl => Fixture.wsdl(:elements_in_types)) + msg = {":TopLevelTransaction"=>{":Qualified"=>"A Value"}} + + response = client.call(:top_level_transaction, :message => msg) + + expect(response.http.body.scan(//).count).to eq(1) + end + end context "global :env_namespace" do