IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBA Access Discussion :

WebService SOAP VIES [AC-2016]


Sujet :

VBA Access

  1. #1
    Membre confirmé
    Inscrit en
    Février 2011
    Messages
    465
    Détails du profil
    Informations forums :
    Inscription : Février 2011
    Messages : 465
    Points : 549
    Points
    549
    Par défaut WebService SOAP VIES
    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 :
    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
    Lorsque je l'exécute, la fenêtre immédiate me donne le message d'erreur :
    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.

  2. #2
    Rédacteur/Modérateur
    Avatar de loufab
    Homme Profil pro
    Entrepreneur en solutions informatiques viables et fonctionnelles.
    Inscrit en
    Avril 2005
    Messages
    12 006
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Pyrénées Atlantiques (Aquitaine)

    Informations professionnelles :
    Activité : Entrepreneur en solutions informatiques viables et fonctionnelles.
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2005
    Messages : 12 006
    Points : 24 598
    Points
    24 598
    Par défaut
    Unexpected wrapper element checkVat found

    Il trouve un élément du checkVat qu'il ne peut convertir (wrapper=convertisseur). Problème de balise ou de type de contenu ?

    Si ça peut t'aider.
    Détecter les modifications formulaire Cloud storage et ACCESS
    Classe MELA(CRUD) Opérateur IN et zone de liste Opérateur LIKE
    Visitez mon Blog
    Les questions techniques par MP ne sont pas lues et je ne pratique pas la bactériomancie

  3. #3
    Membre confirmé
    Inscrit en
    Février 2011
    Messages
    465
    Détails du profil
    Informations forums :
    Inscription : Février 2011
    Messages : 465
    Points : 549
    Points
    549
    Par défaut
    Merci Loufab,
    J'ai un peu sukkellé sur le coup mais je finis par avoir quelque chose qui roule.
    il y avait un problème avec le target nameSpace et puis le avec la ligne Setrequestheader action.
    J'ai reçu une aide précieuse de Tsuji dans le forum Programmation / XML. Si tu le croises sur le Forum, dis-lui merci de ma part.

    Merci et à bientôt.

  4. #4
    Rédacteur/Modérateur
    Avatar de loufab
    Homme Profil pro
    Entrepreneur en solutions informatiques viables et fonctionnelles.
    Inscrit en
    Avril 2005
    Messages
    12 006
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Pyrénées Atlantiques (Aquitaine)

    Informations professionnelles :
    Activité : Entrepreneur en solutions informatiques viables et fonctionnelles.
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2005
    Messages : 12 006
    Points : 24 598
    Points
    24 598
    Par défaut
    parfait !

    Le mieux est de lui envoyé un petit MP.
    Détecter les modifications formulaire Cloud storage et ACCESS
    Classe MELA(CRUD) Opérateur IN et zone de liste Opérateur LIKE
    Visitez mon Blog
    Les questions techniques par MP ne sont pas lues et je ne pratique pas la bactériomancie

  5. #5
    Membre confirmé
    Inscrit en
    Février 2011
    Messages
    465
    Détails du profil
    Informations forums :
    Inscription : Février 2011
    Messages : 465
    Points : 549
    Points
    549
    Par défaut
    Bonjour,

    Je reviens avec mon problème de WebServcie SOAP. Le code suivant fonctionne parfaitement sur un PC avec MS Access 2016 / Windows 10 64 bits.
    Lorsque j'essaye de le faire tourner sur un PC avec MS Access 2007 / Windows 7 32 bits, ça plante !

    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
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    Function VIES_CheckVat()
    'Utilise la Référence Microsoft XML,v6.0
    Dim strResponseText As String
    Dim strURL As String
    Dim strEnv As String
     
    Dim oHttp As Object                       'This works fine in Access 2016
     
     
    'The URL address of the wsdl
    ' "http://ec.europa.eu/taxation_customs/vies/checkVatTestService.wsdl"       'TEST wsdl
    ' "http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl"           'PROD
     
    'creating Enveloppe
    ' 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"" "
    strEnv = strEnv & "xmlns=""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>BE</countryCode>"
    strEnv = strEnv & "    <vatNumber>100</vatNumber>"       'Numéro de tva bidon qui doit me donner un message d'erreur typique
    strEnv = strEnv & "   </checkVat>"
    strEnv = strEnv & "  </soapenv:Body>"
    strEnv = strEnv & "</soapenv:Envelope>"
     
    strURL = "http://ec.europa.eu/taxation_customs/vies/services/checkVatTestService"
    Set oHttp = New MSXML2.XMLHTTP60                                           'works fine on Access 2016
     
    'Enveloppe created. open http POST
    oHttp.Open "POST", strURL, False        'POST, OPEN, GET : Always use uppercase as some servers ignore lowercase HTTP verbs
    'oHttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"          'works fine on Access 2016
    oHttp.setRequestHeader "Content-Type", "text/xml"                          'works fine on Access 2016
    'oHttp.setRequestHeader "Accept", "text/xml"                            'does not change anything....
    oHttp.setRequestHeader "soapAction", ""                                   'works with or without this line in Access 2016
     
    'Sending enveloppe
    'cette ligne fonctionne correctement avec Access 2016 / windows 10 64 bits mais donne "The parameter is incorrect" avec Access 2007 / Windows 7 32 bits
    oHttp.send strEnv
     
    'Cette ligne avec parentheses fonctionne parfaitement avec Access 2016/Windows 10 mais Access 2007/Windows 7 se bloque (reste coincé sur l'horloge et rien ne se passe)
    'oHttp.send (strEnv)
     
    strResponseText = oHttp.responseText
     
    'response received
    Debug.Print strResponseText
     
    Set oHttp = Nothing
     
    End Function
    Avez-vous une idée pourquoi cela coince ?

    Merci.

  6. #6
    Membre confirmé
    Inscrit en
    Février 2011
    Messages
    465
    Détails du profil
    Informations forums :
    Inscription : Février 2011
    Messages : 465
    Points : 549
    Points
    549
    Par défaut
    L'appel HTTP fonctionne en 64 bits mais pas en 32 bits.

  7. #7
    Expert confirmé

    Homme Profil pro
    consultant développeur
    Inscrit en
    Mai 2005
    Messages
    2 878
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : consultant développeur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2005
    Messages : 2 878
    Points : 4 754
    Points
    4 754
    Par défaut
    Bonjour,

    Pour info,
    sous win10 pro 64 bits, access 2010 32 bits
    ça marche chez moi :
    Retour de ta procédure :
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><checkVatResponse xmlns="urn:ec.europa.eu:taxud:vies:services:checkVat:types"><countryCode>BE</countryCode><vatNumber>100</vatNumber><requestDate>2016-12-13+01:00</requestDate><valid>true</valid><name>John Doe</name><address>123 Main St, Anytown, UK</address></checkVatResponse></soap:Body></soap:Envelope>
    Cdlt
    "Always look at the bright side of life." Monty Python.

  8. #8
    Expert éminent sénior
    Avatar de tee_grandbois
    Homme Profil pro
    retraité
    Inscrit en
    Novembre 2004
    Messages
    8 648
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : retraité

    Informations forums :
    Inscription : Novembre 2004
    Messages : 8 648
    Points : 14 626
    Points
    14 626
    Par défaut
    Bonsoir,
    juste pour voir, essaie sans paramètre :
    Quand on est derrière l'écran on n'a aucun clavier sous les mains ...
    ah non ? donc devant l'écran c'est la connectique ?

  9. #9
    Membre confirmé
    Inscrit en
    Février 2011
    Messages
    465
    Détails du profil
    Informations forums :
    Inscription : Février 2011
    Messages : 465
    Points : 549
    Points
    549
    Par défaut
    OK, Merci pour le test.
    Jusqu'à présent, j'ai essayé avec des PC Windows 64 bits et Access 64 bits ou des PC Windows 32 bits et Access 32 bits.

  10. #10
    Membre confirmé
    Inscrit en
    Février 2011
    Messages
    465
    Détails du profil
    Informations forums :
    Inscription : Février 2011
    Messages : 465
    Points : 549
    Points
    549
    Par défaut
    Hééé !sans aucun attribut fonctionne !
    J'ai un autre message d'erreur lié mon réseau mais ça, c'est une autre histoire.

    Merci beaucoup pour la suggestion !
    Je croyais l'avoir déjà utilisée. Sans doute suis-je passé à côté...

    Encore Merci !

  11. #11
    Membre confirmé
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    1 225
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 1 225
    Points : 553
    Points
    553
    Par défaut
    Salut Pipowil,

    Après pas mal de recherche, je viens de lire ton post et je suis très intéressé par ton code.
    Je l'ai essayé mais je tombe sur quelques problèmes, à l'exécution du code voici le message que j’obtiens

    Nom : Erreur_Web_Vies.jpg
Affichages : 742
Taille : 38,3 Ko

    Comment obtiens-tu le résultat correct, même si je plce un numéro de TVA Valide j'ai ce message.

    Merci pour ton aide.

  12. #12
    Membre confirmé
    Inscrit en
    Février 2011
    Messages
    465
    Détails du profil
    Informations forums :
    Inscription : Février 2011
    Messages : 465
    Points : 549
    Points
    549
    Par défaut
    Bonjour,
    Je pense que la commision a changé son webservice. Il y a aussi un autre Webservice checkVatApprox qui est un peu plus interssant parce qu'il donne plus d'information.
    tu peux changer ceci
    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
    strEnv = "<?xml version=""1.0"" encoding=""utf-8""?>"
    strEnv = strEnv & "<SOAP-ENV:Envelope xmlns:ns0=""urn:ec.europa.eu:taxud:vies:services:checkVat:types"" "
    strEnv = strEnv & "xmlns:ns1=""http://schemas.xmlsoap.org/soap/envelope/"" "
    strEnv = strEnv & "xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" "
    strEnv = strEnv & "xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/"">"
    strEnv = strEnv & "  <SOAP-ENV:Header/>"
    strEnv = strEnv & "  <ns1:Body>"
    strEnv = strEnv & "   <ns0:checkVatApprox>"
    strEnv = strEnv & "    <ns0:countryCode>BE</ns0:countryCode>"
    strEnv = strEnv & "    <ns0:vatNumber>0123456789/ns0:vatNumber>"       'the vat nbr we are verifying
    strEnv = strEnv & "    <ns0:traderName/>"
    strEnv = strEnv & "    <ns0:traderCompanyType/>"
    strEnv = strEnv & "    <ns0:traderStreet/>"
    strEnv = strEnv & "    <ns0:traderPostcode/>"
    strEnv = strEnv & "    <ns0:traderCity/>"
    strEnv = strEnv & "    <ns0:requesterCountryCode>xx</ns0:requesterCountryCode>"       'Mettre ici votre country country code
    strEnv = strEnv & "    <ns0:requesterVatNumber>12345</ns0:requesterVatNumber>"      'Mettre ici votre numero de tva personnel parce que la demande est faite en votre nom.
    strEnv = strEnv & "   </ns0:checkVatApprox>"
    strEnv = strEnv & "  </ns1:Body>"
    strEnv = strEnv & "</SOAP-ENV:Envelope>"

  13. #13
    Membre confirmé
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    1 225
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 1 225
    Points : 553
    Points
    553
    Par défaut
    Salut PipoWil,

    Merci pour ta réponse,

    Il me faudrait un peu plus d'info concernant le code que tu as mis, je ne suis pas un pro de la programmation
    Une fois que je clic sur le bouton dans mon form pour appeler la function, la page web Vies s'affiche dans FireFox mais comment je sais que le numéro est valide ou non?

    Voici les MsgBox
    Nom : 2019-09-23_18-21-35.jpg
Affichages : 730
Taille : 85,3 Ko
    Nom : 2019-09-23_18-21-53.jpg
Affichages : 731
Taille : 47,8 Ko

    Merci pour ton aide

  14. #14
    Membre confirmé
    Inscrit en
    Février 2011
    Messages
    465
    Détails du profil
    Informations forums :
    Inscription : Février 2011
    Messages : 465
    Points : 549
    Points
    549
    Par défaut
    Bonjour,

    Aucune page web n'est supposée s'ouvrir. C'est un Webservice.
    Dans le précédent code, remplacez strEnv par les lignes strEnv que je vous ai envoyées ce matin. Le résultat doit apparaître dans la fenêtre immédiate.
    Ensuite vous adapterez pour votre application.

  15. #15
    Membre confirmé
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    1 225
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 1 225
    Points : 553
    Points
    553
    Par défaut
    Autant pour moi,

    une ancienne ligne de code qui ouvrait IE était présente dans la procédure d'appel de la function.

    Voici le code que j'ai

    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
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    Function VIES_CheckVat()
    'Utilise la Référence Microsoft XML,v6.0
    Dim strResponseText As String
    Dim strURL As String
    Dim strEnv As String
     
    Dim oHttp As Object                       'This works fine in Access 2016
     
     
    'The URL address of the wsdl
    ' "http://ec.europa.eu/taxation_customs/vies/checkVatTestService.wsdl"       'TEST wsdl
    ' "http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl"           'PROD
     
    'creating Enveloppe
    ' 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"" "
    'strEnv = strEnv & "xmlns=""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>BE</countryCode>" 'Code Pays BE
    'strEnv = strEnv & "    <vatNumber>0464407690</vatNumber>"       'Numéro de tva bidon qui doit me donner un message d'erreur typique
    'strEnv = strEnv & "   </checkVat>"
    'strEnv = strEnv & "  </soapenv:Body>"
    'strEnv = strEnv & "</soapenv:Envelope>"
     
     
    '************ NEW CODE ***************
     strEnv = "<?xml version=""1.0"" encoding=""utf-8""?>"
    strEnv = strEnv & "<SOAP-ENV:Envelope xmlns:ns0=""urn:ec.europa.eu:taxud:vies:services:checkVat:types"" "
    strEnv = strEnv & "xmlns:ns1=""http://schemas.xmlsoap.org/soap/envelope/"" "
    strEnv = strEnv & "xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" "
    strEnv = strEnv & "xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/"">"
    strEnv = strEnv & "  <SOAP-ENV:Header/>"
    strEnv = strEnv & "  <ns1:Body>"
    strEnv = strEnv & "   <ns0:checkVatApprox>"
    strEnv = strEnv & "    <ns0:countryCode>BE</ns0:countryCode>"
    strEnv = strEnv & "    <ns0:vatNumber>0423980367/ns0:vatNumber>"       'the vat nbr we are verifying
    strEnv = strEnv & "    <ns0:traderName/>"
    strEnv = strEnv & "    <ns0:traderCompanyType/>"
    strEnv = strEnv & "    <ns0:traderStreet/>"
    strEnv = strEnv & "    <ns0:traderPostcode/>"
    strEnv = strEnv & "    <ns0:traderCity/>"
    strEnv = strEnv & "    <ns0:requesterCountryCode>BE</ns0:requesterCountryCode>"       'Mettre ici votre country country code
    strEnv = strEnv & "    <ns0:requesterVatNumber>01234</ns0:requesterVatNumber>"      'Mettre ici votre numero de tva personnel parce que la demande est faite en votre nom.
    strEnv = strEnv & "   </ns0:checkVatApprox>"
    strEnv = strEnv & "  </ns1:Body>"
    strEnv = strEnv & "</SOAP-ENV:Envelope>"
     
     
    strURL = "http://ec.europa.eu/taxation_customs/vies/services/checkVatTestService"
    Set oHttp = New MSXML2.XMLHTTP60                                           'works fine on Access 2016
     
    'Enveloppe created. open http POST
    oHttp.Open "POST", strURL, False        'POST, OPEN, GET : Always use uppercase as some servers ignore lowercase HTTP verbs
    'oHttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"          'works fine on Access 2016
    oHttp.setRequestHeader "Content-Type", "text/xml"                          'works fine on Access 2016
    'oHttp.setRequestHeader "Accept", "text/xml"                            'does not change anything....
    oHttp.setRequestHeader "soapAction", ""                                   'works with or without this line in Access 2016
     
    'Sending enveloppe
    'cette ligne fonctionne correctement avec Access 2016 / windows 10 64 bits mais donne "The parameter is incorrect" avec Access 2007 / Windows 7 32 bits
    oHttp.send strEnv
     
    MsgBox (strEnv)
     
    'Cette ligne avec parentheses fonctionne parfaitement avec Access 2016/Windows 10 mais Access 2007/Windows 7 se bloque (reste coincé sur l'horloge et rien ne se passe)
    'oHttp.send (strEnv)
     
    strResponseText = oHttp.responseText
     
    'response received
    Debug.Print strResponseText
    MsgBox (strResponseText)
     
    Set oHttp = Nothing
     
    End Function

  16. #16
    Membre confirmé
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    1 225
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 1 225
    Points : 553
    Points
    553
    Par défaut
    Salut PipoWil,

    Désolé de t’embêter avec ça, mais je n'arrive toujours pas à avoir un résultat pour la demande de validité du N° de TVA.

    Voici les messages que j'ai

    Nom : 2019-09-23_18-21-35.jpg
Affichages : 690
Taille : 85,3 Ko

    Ensuite

    Nom : 2019-09-27_11-54-42.jpg
Affichages : 687
Taille : 38,0 Ko

    Merci pour ton aide

    Bien à toi,

  17. #17
    Membre confirmé
    Inscrit en
    Février 2011
    Messages
    465
    Détails du profil
    Informations forums :
    Inscription : Février 2011
    Messages : 465
    Points : 549
    Points
    549
    Par défaut
    Ceci fonctionne simplement.
    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
    Function X()
    Dim strResponseText As String
    Dim strURL As String
    Dim strEnv As String
    Dim xmlhtp As MSXML2.XMLHTTP60
     
    'creating Enveloppe
    ' we create our SOAP envelope for submission to the Web Service
    strEnv = "<?xml version=""1.0"" encoding=""utf-8""?>"
    strEnv = strEnv & "<SOAP-ENV:Envelope xmlns:ns0=""urn:ec.europa.eu:taxud:vies:services:checkVat:types"" "
    strEnv = strEnv & "xmlns:ns1=""http://schemas.xmlsoap.org/soap/envelope/"" "
    strEnv = strEnv & "xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" "
    strEnv = strEnv & "xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/"">"
    strEnv = strEnv & "  <SOAP-ENV:Header/>"
    strEnv = strEnv & "  <ns1:Body>"
    strEnv = strEnv & "   <ns0:checkVatApprox>"
    strEnv = strEnv & "    <ns0:countryCode>DE</ns0:countryCode>"
    strEnv = strEnv & "    <ns0:vatNumber>1234</ns0:vatNumber>"       'the vat nbr we are verifying
    strEnv = strEnv & "    <ns0:traderName/>"
    strEnv = strEnv & "    <ns0:traderCompanyType/>"
    strEnv = strEnv & "    <ns0:traderStreet/>"
    strEnv = strEnv & "    <ns0:traderPostcode/>"
    strEnv = strEnv & "    <ns0:traderCity/>"
    strEnv = strEnv & "    <ns0:requesterCountryCode>BE</ns0:requesterCountryCode>"
    strEnv = strEnv & "    <ns0:requesterVatNumber>0123456789</ns0:requesterVatNumber>"
    strEnv = strEnv & "   </ns0:checkVatApprox>"
    strEnv = strEnv & "  </ns1:Body>"
    strEnv = strEnv & "</SOAP-ENV:Envelope>"
     
    'The URL address of the wsdl
    strURL = "http://ec.europa.eu/taxation_customs/vies/services/checkVatService"
     
    Set xmlhtp = New MSXML2.XMLHTTP60
     
    'Enveloppe created. open http POST
    xmlhtp.Open "POST", strURL, False
     
    xmlhtp.setRequestHeader "Content-Type", "text/xml"
     
    'Sending enveloppe
    xmlhtp.send strEnv
    strResponseText = xmlhtp.responseText
     
    Debug.Print strResponseText
     
    Set xmlhtp = Nothing
     
    End Function

  18. #18
    Membre confirmé
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    1 225
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 1 225
    Points : 553
    Points
    553
    Par défaut
    Re,

    Ok, merci pour le code, j'ai bien False ou True dans la balise Valid.

    Il me reste à voir pour récupérer cette réponse et continuer le code en fonction de la réponse.

    Merci

  19. #19
    Membre confirmé
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    1 225
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 1 225
    Points : 553
    Points
    553
    Par défaut
    Re,

    OK, je pense que c'est bon, j'ai réussi AVEC TON AIDE PRECIEUSE, à accéder au site et à récupérer les données.

    Encore Merci

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 2
    Dernier message: 19/09/2009, 10h02
  2. [Web Service] Appel Webservice SOAP
    Par HaTnuX dans le forum Bibliothèques et frameworks
    Réponses: 1
    Dernier message: 16/08/2008, 22h33
  3. webservices soap et php
    Par manuscle dans le forum WinDev
    Réponses: 0
    Dernier message: 16/04/2008, 16h35
  4. Réponses: 1
    Dernier message: 13/02/2007, 17h43
  5. Webservice SOAP et fichier attaché ?
    Par Bruno13 dans le forum Services Web
    Réponses: 13
    Dernier message: 03/04/2006, 17h36

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo