Skip to content

Commit

Permalink
Fix elementFormDefault="qualified" regression (#917)
Browse files Browse the repository at this point in the history
Types were not properly qualified
This test is based on a simplified real world wsdl
  • Loading branch information
Lukas Oberhuber authored and pcai committed Jul 5, 2020
1 parent 0b5558e commit f4770e9
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/savon/qualified_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 43 additions & 0 deletions spec/fixtures/wsdl/elements_in_types.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="www.example.com/XML" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s1="http://microsoft.com/wsdl/types/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="www.example.com/XML" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="www.example.com/XML">
<s:complexType name="Transaction" abstract="true">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Qualified" type="s:string" />
</s:sequence>
</s:complexType>
<s:complexType name="TopLevelTransaction">
<s:complexContent mixed="false">
<s:extension base="tns:Transaction">
</s:extension>
</s:complexContent>
</s:complexType>
<s:element name="TopLevelTransaction">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="TopLevelTransaction" type="tns:TopLevelTransaction" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="TopLevelTransactionSoapIn">
<wsdl:part name="parameters" element="tns:TopLevelTransaction" />
</wsdl:message>
<wsdl:portType name="XMLTESoap">
<wsdl:operation name="TopLevelTransaction">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">TopLevelTransaction.</wsdl:documentation>
<wsdl:input message="tns:TopLevelTransactionSoapIn" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="XMLTESoap12" type="tns:XMLTESoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="TopLevelTransaction">
<soap12:operation soapAction="www.example.com/XML/TopLevelTransaction" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
</wsdl:operation>
</wsdl:binding>
</wsdl:definitions>
11 changes: 11 additions & 0 deletions spec/savon/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,17 @@ def to_s
expect(response.http.body).to include("<user>lea</user>")
expect(response.http.body).to include("<password>top-secret</password>")
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(/<tns:Qualified>/).count).to eq(1)
end

end

context "global :env_namespace" do
Expand Down

0 comments on commit f4770e9

Please sign in to comment.