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

Compute correct namespace for message tags #476

Merged
merged 3 commits into from
Jul 2, 2013
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
`Savon::Response#body` to respect the global `:convert_response_tags_to` and `:strip_namespaces`
options and return the expected result instead of raising a `Savon::InvalidResponseError`.

* Fix: [#476](https://github.com/savonrb/savon/issues/476) fixes a problem where the namespace
for the message tag was not correctly determined from the WSDL.

### 2.2.0 (2013-04-21)

* Feature: [#416](https://github.com/savonrb/savon/pull/416) The global `namespace_identifier`
Expand Down
9 changes: 5 additions & 4 deletions lib/savon/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,13 @@ def header
end

def namespaced_message_tag
tag_name = message_tag
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]
[tag_name, message_attributes]
elsif @used_namespaces[[tag_name.to_s]]
[@used_namespaces[[tag_name.to_s]], tag_name, message_attributes]
else
[namespace_identifier, message_tag, message_attributes]
[namespace_identifier, tag_name, message_attributes]
end
end

Expand Down
176 changes: 176 additions & 0 deletions spec/fixtures/wsdl/vies.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="urn:ec.europa.eu:taxud:vies:services:checkVat" xmlns:tns1="urn:ec.europa.eu:taxud:vies:services:checkVat:types" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:impl="urn:ec.europa.eu:taxud:vies:services:checkVat" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/">
<xsd:documentation>
Specific disclaimer for this service ----------------------------------------- The
objective of this Internet site is to allow persons involved in the intra-Community supply of
goods or of services to obtain confirmation of the validity of the VAT identification number of
any specified person, in accordance to article 27 of Council Regulation (EC) No. 1798/2003 of 7
October 2003. Any other use and any extraction and use of the data which is not in conformity
with the objective of this site is strictly forbidden. Any retransmission of the contents of
this site, whether for a commercial purpose or otherwise, as well as any more general use other
than as far as is necessary to support the activity of a legitimate user (for example: to draw
up their own invoices) is expressly forbidden. In addition, any copying or reproduction of the
contents of this site is strictly forbidden. The European Commission maintains this website to
enhance the access by taxable persons making intra-Community supplies to verification of their
customers VAT identification numbers. Our goal is to supply instantaneous and accurate
information. However the Commission accepts no responsibility or liability whatsoever with
regard to the information obtained using this site. This information: - is obtained from Member
States databases over which the Commission services have no control and for which the Commission
assumes no responsibility; it is the responsibility of the Member States to keep their databases
complete, accurate and up to date; - is not professional or legal advice (if you need specific
advice, you should always consult a suitably qualified professional); - does not in itself give
a right to exempt intra-Community supplies from Value Added Tax; - does not change any
obligations imposed on taxable persons in relation to intra-Community supplies. It is our goal
to minimise disruption caused by technical errors. However some data or information on our site
may have been created or structured in files or formats which are not error-free and we cannot
guarantee that our service will not be interrupted or otherwise affected by such problems. The
Commission accepts no responsibility with regard to such problems incurred as a result of using
this site or any linked external sites. This disclaimer is not intended to limit the liability
of the Commission in contravention of any requirements laid down in applicable national law nor
to exclude its liability for matters which may not be excluded under that law. Usage: The
countryCode input parameter must follow the pattern [A-Z]{2} The vatNumber input parameter must
follow the [0-9A-Za-z\+\*\.]{2,12} In case of problem, the returned FaultString can take the
following specific values: - INVALID_INPUT: The provided CountryCode is invalid or the VAT
number is empty; - SERVICE_UNAVAILABLE: The SOAP service is unavailable, try again later; -
MS_UNAVAILABLE: The Member State service is unavailable, try again later or with another Member
State; - TIMEOUT: The Member State service could not be reach in time, try again later or with
another Member State; - SERVER_BUSY: The service can't process your request. Try again latter.
</xsd:documentation>

<wsdl:types>
<xsd:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="urn:ec.europa.eu:taxud:vies:services:checkVat:types" xmlns="urn:ec.europa.eu:taxud:vies:services:checkVat:types">
<xsd:element name="checkVat">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="countryCode" type="xsd:string"/>
<xsd:element name="vatNumber" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="checkVatResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="countryCode" type="xsd:string"/>
<xsd:element name="vatNumber" type="xsd:string"/>
<xsd:element name="requestDate" type="xsd:date"/>
<xsd:element name="valid" type="xsd:boolean"/>
<xsd:element maxOccurs="1" minOccurs="0" name="name" nillable="true" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="address" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="checkVatApprox">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="countryCode" type="xsd:string"/>
<xsd:element name="vatNumber" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="traderName" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="traderCompanyType" type="tns1:companyTypeCode"/>
<xsd:element maxOccurs="1" minOccurs="0" name="traderStreet" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="traderPostcode" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="traderCity" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="requesterCountryCode" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="requesterVatNumber" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="checkVatApproxResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="countryCode" type="xsd:string"/>
<xsd:element name="vatNumber" type="xsd:string"/>
<xsd:element name="requestDate" type="xsd:date"/>
<xsd:element name="valid" type="xsd:boolean"/>
<xsd:element maxOccurs="1" minOccurs="0" name="traderName" nillable="true" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="traderCompanyType" nillable="true" type="tns1:companyTypeCode"/>
<xsd:element maxOccurs="1" minOccurs="0" name="traderAddress" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="traderStreet" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="traderPostcode" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="traderCity" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="traderNameMatch" type="tns1:matchCode"/>
<xsd:element maxOccurs="1" minOccurs="0" name="traderCompanyTypeMatch" type="tns1:matchCode"/>
<xsd:element maxOccurs="1" minOccurs="0" name="traderStreetMatch" type="tns1:matchCode"/>
<xsd:element maxOccurs="1" minOccurs="0" name="traderPostcodeMatch" type="tns1:matchCode"/>
<xsd:element maxOccurs="1" minOccurs="0" name="traderCityMatch" type="tns1:matchCode"/>
<xsd:element name="requestIdentifier" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:simpleType name="companyTypeCode">
<xsd:restriction base="xsd:string">
<xsd:pattern value="[A-Z]{2}\-[1-9][0-9]?"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="matchCode">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="1">
<xsd:annotation>
<xsd:documentation>VALID</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="2">
<xsd:annotation>
<xsd:documentation>INVALID</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="checkVatRequest">
<wsdl:part name="parameters" element="tns1:checkVat">
</wsdl:part>
</wsdl:message>
<wsdl:message name="checkVatApproxResponse">
<wsdl:part name="parameters" element="tns1:checkVatApproxResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="checkVatApproxRequest">
<wsdl:part name="parameters" element="tns1:checkVatApprox">
</wsdl:part>
</wsdl:message>
<wsdl:message name="checkVatResponse">
<wsdl:part name="parameters" element="tns1:checkVatResponse">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="checkVatPortType">
<wsdl:operation name="checkVat">
<wsdl:input name="checkVatRequest" message="impl:checkVatRequest">
</wsdl:input>
<wsdl:output name="checkVatResponse" message="impl:checkVatResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="checkVatApprox">
<wsdl:input name="checkVatApproxRequest" message="impl:checkVatApproxRequest">
</wsdl:input>
<wsdl:output name="checkVatApproxResponse" message="impl:checkVatApproxResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="checkVatBinding" type="impl:checkVatPortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="checkVat">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="checkVatRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="checkVatResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="checkVatApprox">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="checkVatApproxRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="checkVatApproxResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="checkVatService">
<wsdl:port name="checkVatPort" binding="impl:checkVatBinding">
<wsdlsoap:address location="http://ec.europa.eu/taxation_customs/vies/services/checkVatService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
5 changes: 5 additions & 0 deletions spec/savon/features/message_tag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
expect(message_tag).to eq(['http://www.betfair.com/publicapi/v5/BFExchangeService/', 'getBet'])
end

it 'knows the message tag for :vies' do
message_tag = message_tag_for(:vies, :check_vat)
expect(message_tag).to eq(['urn:ec.europa.eu:taxud:vies:services:checkVat:types', 'checkVat'])
end

it 'knows the message tag for :wasmuth' do
message_tag = message_tag_for(:wasmuth, :get_st_tables)
expect(message_tag).to eq(['http://ws.online.msw/', 'getStTables'])
Expand Down