Reputation: 1237
I am trying to implement an automated VAT validation as provided by: http://ec.europa.eu/taxation_customs/vies/technicalInformation.html
Basically, the code I wrote sends a number of requests and writes the response in excel. the problem is i cannot find why I don't get a response for what i need, or rather, the response as it should be as per example.
part of the code with the request:
>import reqests
>url='http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl'
>headers = {'content-type': 'text/soap+xml'}
>body= """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >
> <soapenv:Header/>
> <soapenv:Body>
> <urn:checkVat xmlns:urn="urn:ec.europa.eu:taxud:vies:services:checkVat:types">
> <urn:countryCode>NL</urn:countryCode>
> <urn:vatNumber>800938495B01</urn:vatNumber>
> </urn:checkVat>
> </soapenv:Body>
> </soapenv:Envelope>"""
>
>r=requests.post(url, data=body, headers=headers)
>r.status_code
>print(r.text)
I get as a response the very content of the page http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl and not the respons as per example.
exapme request:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<urn:checkVat
xmlns:urn="urn:ec.europa.eu:taxud:vies:services:checkVat:types">
<urn:countryCode>NL</urn:countryCode>
<urn:vatNumber>800938495B01</urn:vatNumber>
</urn:checkVat>
</soapenv:Body>
</soapenv:Envelope>
example response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<urn:checkVatResponse
xmlns:urn="urn:ec.europa.eu:taxud:vies:services:checkVat:types">
<urn:countryCode>NL</urn:countryCode>
<urn:vatNumber> 800938495B01</urn:vatNumber>
<urn:requestDate>2010-06-28+02:00</urn:requestDate>
<urn:valid>true</urn:valid>
</urn:checkVatResponse>
</soapenv:Body>
some other valid codes to check are:
DE 147799609
SK 2023661948
CZ 26697131
I know there are some working programs on web developed in php and .net, but I wonder if I can get it working with python, as it is a part of a bigger process.
Upvotes: 3
Views: 9090
Reputation: 1237
Managed to do it with suds-jurko
> from suds.client import Client
> url="http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl"
> client = Client(url)
> print(client) # to check the methonds
> r=client.service.checkVat('NL', '800938495B01')
> print(r)
It is not exactly as per example, but it returns the needed data.
Upvotes: 2