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, soit vous utilisez le webservice prévu à cet effet.
J'essaye d'utiliser le WebService SOAP (voir FAQ 16 du site VIES) mais je ne parviens pas à résoudre mon erreur.
Voici mon code VBA :
Lorsque je l'exécute, la fenêtre immédiate me donne le message d'erreur :
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>SL</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 Function
Code xml : 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>
Je ne comprends pas ce message d'erreur. Qu'est-ce qu'il veut dire ?
Merci.
Partager