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 51 52
| 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 xmlns""urn:ec.europa.eu:taxud:vies:services:checkVat"" " 'xmlns au lieu de targetNamespace
strEnv = strEnv & "xmlns:tns1=""urn:ec.europa.eu:taxud:vies:services:checkVat:types"" "
strEnv = strEnv & "xmlns:soapenc=""http://schemas.xmlsoap.org/soap/encoding/"" "
strEnv = strEnv & "xmlns:impl=""urn:ec.europa.eu:taxud:vies:services:checkVat"" "
strEnv = strEnv & "xmlns:apachesoap=""http://xml.apache.org/xml-soap"" "
strEnv = strEnv & "xmlns:wsdl=""http://schemas.xmlsoap.org/wsdl/"" "
strEnv = strEnv & "xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" "
strEnv = strEnv & "xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" >"
strEnv = strEnv & "xmlns:wsdlsoap=""http://schemas.xmlsoap.org/wsdl/soap/"" "
strEnv = strEnv & " <soapenv:Header/>"
strEnv = strEnv & " <soapenv:Body>"
strEnv = strEnv & " <checkVat>"
strEnv = strEnv & " <countryCode>FI</countryCode>"
strEnv = strEnv & " <vatNumber>202</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", ""
xmlhtp.send strEnv
strResponseText = xmlhtp.responseText
Debug.Print strResponseText
Set xmlhtp = Nothing
End Function |