From 1e70edb10d420b0b4502c54002e5ae00495efd5a Mon Sep 17 00:00:00 2001 From: Andrew Arderne Date: Fri, 12 Aug 2022 12:27:51 +0100 Subject: [PATCH] ES-868: Fix schema change --- pyvat/registries.py | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/pyvat/registries.py b/pyvat/registries.py index b5a1f24..28b681b 100644 --- a/pyvat/registries.py +++ b/pyvat/registries.py @@ -103,31 +103,34 @@ def check_vat_number(self, vat_number, country_code): # We basically expect the result structure to be as follows, # where the address and name nodes might be omitted. # - # - # - # - # .. - # .. - # .. - # .. - # .. - #
..
- #
- #
- #
+ # + # + # + # + # DE + # 812383453 + # 2022-08-12+02:00 + # true + # --- + # --- + # + # + # result_dom = xml.dom.minidom.parseString(response.text.encode('utf-8')) envelope_node = result_dom.documentElement - if envelope_node.tagName != 'soap:Envelope': + if envelope_node.tagName != 'env:Envelope': raise ValueError( 'expected response XML root element to be a SOAP envelope' ) - body_node = get_first_child_element(envelope_node, 'soap:Body') + body_node = get_first_child_element(envelope_node, 'env:Body') # Check for server errors try: - error_node = get_first_child_element(body_node, 'soap:Fault') + error_node = get_first_child_element(body_node, 'env:Fault') fault_strings = error_node.getElementsByTagName('faultstring') fault_code = fault_strings[0].firstChild.nodeValue raise ServerError(fault_code) @@ -137,11 +140,11 @@ def check_vat_number(self, vat_number, country_code): try: check_vat_response_node = get_first_child_element( body_node, - 'checkVatResponse' + 'ns2:checkVatResponse' ) valid_node = get_first_child_element( check_vat_response_node, - 'valid' + 'ns2:valid' ) except Exception as e: result.log_lines.append(u'< Response is nondeterministic due to ' @@ -162,7 +165,7 @@ def check_vat_number(self, vat_number, country_code): try: name_node = get_first_child_element( check_vat_response_node, - 'name' + 'ns2:name' ) result.business_name = get_text(name_node).strip() or None except Exception: @@ -171,7 +174,7 @@ def check_vat_number(self, vat_number, country_code): try: address_node = get_first_child_element( check_vat_response_node, - 'address' + 'ns2:address' ) result.business_address = get_text(address_node).strip() or None except Exception: