Bonjour,
Le site VIES des Communautés Européennes permet de vérifier des numéros de TVA.
Vous pouvez ouvrir Internet Explorer à l'adresse http://ec.europa.eu/taxation_customs...atRequest.html et vous l'utilisez manuellement ou vous utilisez le webservice prévu à cet effet.
J'essaye d'utiliser le WebService SOAP dont voici le wsdl mais je ne parviens pas à résoudre mon erreur parce que je ne maîtrise pas bien les concepts du wsdl et l'enveloppe.
Voici mon code (c'est du VBA Microsoft Office) :En clair, l'enveloppe que j'envoie est
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 Function VIES() 'utilise la référence "Micorosoft XML, V6.0" Dim strResponseText As String Dim strURL As String Dim strEnv As String Dim xmlhtp As MSXML2.XMLHTTP60 'The URL address of the wsdl strURL = "http://ec.europa.eu/taxation_customs/vies/checkVatTestService.wsdl" 'TEST wsdl 'strURL = "http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl" 'PROD beware of blacklisting !! ' we create our SOAP envelope for submission to the Web Service strEnv = "<?xml version=""1.0"" encoding=""utf-8""?>" 'je reprends tous les elements du début(definition) du wsdl : strEnv = strEnv & "<soapenv:Envelope targetNamespace=""urn:ec.europa.eu:taxud:vies:services:checkVat"" " strEnv = strEnv & "xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" " strEnv = strEnv & "xmlns:apachesoap=""http://xml.apache.org/xml-soap"" " strEnv = strEnv & "xmlns:impl=""urn:ec.europa.eu:taxud:vies:services:checkVat"" " strEnv = strEnv & "xmlns:soapenc=""http://schemas.xmlsoap.org/soap/encoding/"" " strEnv = strEnv & "xmlns:tns1=""urn:ec.europa.eu:taxud:vies:services:checkVat:types"" " strEnv = strEnv & "xmlns:wsdl=""http://schemas.xmlsoap.org/wsdl/"" " strEnv = strEnv & "xmlns:wsdlsoap=""http://schemas.xmlsoap.org/wsdl/soap/"" " strEnv = strEnv & "xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" >" strEnv = strEnv & " <soapenv:Header/>" strEnv = strEnv & " <soapenv:Body>" strEnv = strEnv & " <checkVat>" strEnv = strEnv & " <countryCode>LU</countryCode>" strEnv = strEnv & " <vatNumber>200</vatNumber>" strEnv = strEnv & " </checkVat>" strEnv = strEnv & " </soapenv:Body>" strEnv = strEnv & "</soapenv:Envelope>" strURL = "http://ec.europa.eu/taxation_customs/vies/services/checkVatTestService" Set xmlhtp = New MSXML2.XMLHTTP60 xmlhtp.Open "POST", strURL, False 'POST, OPEN, GET : Always use uppercase as some servers ignore lowercase HTTP verbs xmlhtp.setRequestHeader "Content-Type", "text/xml; charset=utf-8" xmlhtp.setRequestHeader "soapAction", "checkVatRequest" xmlhtp.send strEnv strResponseText = xmlhtp.responseText Debug.Print strResponseText Set xmlhtp = Nothing End Functionmais la réponse que je reçois me déçoit :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 <soapenv:Envelope targetNamespace="urn:ec.europa.eu:taxud:vies:services:checkVat" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="urn:ec.europa.eu:taxud:vies:services:checkVat" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="urn:ec.europa.eu:taxud:vies:services:checkVat:types" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soapenv:Header/> <soapenv:Body> <checkVat> <countryCode>LU</countryCode> <vatNumber>200</vatNumber> </checkVat> </soapenv:Body> </soapenv:Envelope>Je ne comprends pas cette réponse.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <soap:Fault> <faultcode>soap:Client</faultcode> <faultstring>Unexpected wrapper element checkVat found. Expected {urn:ec.europa.eu:taxud:vies:services:checkVat:types}checkVat.</faultstring> </soap:Fault> </soap:Body> </soap:Envelope>
checkVat est bien une opération du Webservice et checkVat doit contenir 2 éléments, dans l'ordre: countryCode puis vatNumber.
Il y a donc quelque chose d'autre qui coince.
Merci pour vos explications.
Partager