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

Bibliothèques et frameworks PHP Discussion :

erreur api soap


Sujet :

Bibliothèques et frameworks PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Femme Profil pro
    Développeur Web
    Inscrit en
    Janvier 2022
    Messages
    89
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 44
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Santé

    Informations forums :
    Inscription : Janvier 2022
    Messages : 89
    Par défaut erreur api soap
    Bonjour,
    Je dois intégrer une api soap dans un formulaire en PHP
    Je n'arrive pas à me connecter à celle-ci ( je ne vois pas où ajouter l'usernane et le password)
    J'ai déjà essayé de mettre le wsdl à la fin de mon url mais rien n'y fait.
    J'ai une erreur:
    SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://wsdnarec.haras-nationaux.fr/dnaservices/DiffusionServices' : failed to load external entity "http://wsdnarec.haras-nationaux.fr/dnaservices/DiffusionServices"
    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
    <?php
    try{
        $soapclient=new SoapClient('http://wsdnarec.haras-nationaux.fr/dnaservices/DiffusionServices');
        $param=array(
            'isoLangage'=>'EN',
            'utilisateurID'=>'LABEO',
            'applicationID'=>'WSDNA',
            'identID'=>'526797',
            'identKey'=>'T');
     
        $response= $soapclient->getInformationPreleveur($param);
     
        var_dump($response);
        echo'<br><br><br>';
     
        $array=json_encode($response,true);
        print_r($array);
     
        echo'<br><br><br>';
            echo'<br><br><br>';
            foreach ($array as $item){
                echo '<pre>';
                var_dump($item);
            }
     
     
    }catch(Exception $e){
           echo $e->getMessage();
     
    ?>
    }
    Merci de votre aide si vous pouvez m'éclairer

  2. #2
    Membre émérite
    Homme Profil pro
    Autre
    Inscrit en
    Juillet 2021
    Messages
    435
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Autre

    Informations forums :
    Inscription : Juillet 2021
    Messages : 435
    Par défaut
    Bonjour,

    Peut-être voir si les exemples sur la documentation peuvent aider :
    https://www.php.net/manual/fr/soapclient.construct.php

    Bonne journée,

  3. #3
    Membre confirmé
    Femme Profil pro
    Développeur Web
    Inscrit en
    Janvier 2022
    Messages
    89
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 44
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Santé

    Informations forums :
    Inscription : Janvier 2022
    Messages : 89
    Par défaut récupation données depuis xml impossible
    J'ai reussi a me connecter à l'api SOAP.
    J obtenai un resultat uniquement avec des balises fermante donc je n'arrivais a rien récupérer.
    Maintenant j'obtiens bien du xml dans ma réponse sauf que je n'arrive pas à extraire par ex nom ou adresse .
    J'ai essayé différentes méthodes donc voici mon code avec plein de chose en commentaire qui ne marche pas

    Nom : 2022-02-09_14h46_14.png
Affichages : 357
Taille : 65,6 Ko

    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
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    <?php
    $url='http://wsdnarec.haras-nationaux.fr/dnaservices/DiffusionServices';
     
    $curl = curl_init();
     
    curl_setopt_array($curl, array(
      CURLOPT_URL => $url,
      CURLOPT_USERNAME=>'labeo',
      CURLOPT_PASSWORD=>'',
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => '',
     
      CURLOPT_TIMEOUT => 30,
      CURLOPT_FOLLOWLOCATION => true,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => 'POST',
      CURLOPT_POSTFIELDS =>'
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webServices.server.ifce.fr/">
     <soapenv:Header/>
     <soapenv:Body>
     <web:getInformationPreleveur>
     <!--Optional:-->
     <infoPreleveurIn>
     <!--Optional:-->
     <contextHn>
     <!--Optional:-->
     <isoLangage>EN</isoLangage>
     <!--Optional:-->
     <utilisateurID>LABEO</utilisateurID>
     <!--Optional:-->
     <applicationID>WSDNA</applicationID>
     </contextHn>
     <!--Optional:-->
     <identID>526797</identID>
     <!--Optional:-->
     <identKey>T</identKey>
     </infoPreleveurIn>
     </web:getInformationPreleveur>
     </soapenv:Body>
    </soapenv:Envelope>',
      CURLOPT_HTTPHEADER => array(
     
        'Content-Type:application/soap+xml'
        // 'Content-type: text/xml' 
     
     
      ),
    ));
     
    $response = curl_exec($curl);
    $err=curl_error($curl);
     
    curl_close($curl);
     
    if ($err) {
      return "cURL Error #:" . $err;
    } else {
      echo "url : ok";
    }
     
    echo '<br><br><br>';
     
    echo "<pre>", htmlspecialchars($response), "</pre>"; 
    // var_dump($response);// affiche string (676) + la chaine de caractère 
    // echo $response; // affiche la chaine de caractère 
     
    echo '<br><br><br>';
    // $xml = simplexml_load_file( htmlspecialchars($response)); //htmlspecialchars permets de transformer en XML
    $res= htmlspecialchars($response);
    echo"reponse res: $res" ;
     
     
    // $homepage = file_get_contents($response);
    // echo"reponse homepage :  $homepage";
     
        //tu peux accéder aux éléments comme ça: (un élément est défini par <qqch>element</qqch>
        // foreach( $res as $element ) 
        // { 
        //     print_r( $element ); 
        // } 
     
        // echo '<br><br><br>';
        // $xml =simplexml_load_file($res);
        // echo $xml;
     
    //--------------------------------------------encodage------------------------------------//
    echo '<br><br><br>';
    // var_dump(json_decode($response)) ; // reponse :null
     
     
     
    echo'<br><br><br>';
     
     
     
     
    // problème, il affiche également le status 200 même si erreur dans l'identKey
    // var_dump(http_response_code());//affichage du code erreur
    echo'<br><br><br>';
     
    // $xml = simplexml_load_file($response);
    // $appel=$xml;
    // echo $appel;
     
    // echo($xml);
    // var_dump($response);
     
    echo '<br><br><br>';
     
     
    //-------------------------------------------------coupage de chaine--------------------------------//
     
    // $xml="Warning: simplexml_load_file(): I/O warning : failed to load external entity \"<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Header></env:Header><env:Body><ns2:getInformationPreleveurResponse xmlns:ns2=\"http://webServices.server.ifce.fr/\"><informationPreleveur><adresse1>4 PLACE DE L'EGLISE</adresse1><civilite>MME</civilite><codePostal>62128</codePostal><commune>CROISILLES</commune><dateDebutFonction>2013-11-14</dateDebutFonction><mail>72880@ifce.fr</mail><nom>GENTY</nom><nuIdentificateur>526797</nuIdentificateur><nuperso>72880</nuperso><prenom>ANNE</prenom><telFixe>+33 (0)555555555</telFixe><telPortable>+33 (0)606060606</telPortable></informationPreleveur></ns2:getInformationPreleveurResponse></env:Body></env:Envelope>\"in C:\MAMP\htdocs\api\index.php on line 64";
    $xml=htmlspecialchars($response);
    echo $xml;
     
     
    $Search = "telPortable";
    // echo $Search;
    // echo $response;
    // echo $curl;
     
    echo '<br><br><br>';
     
    $IndexDebut = strpos($xml,$Search);
    echo $IndexDebut;
     
    echo '<br><br><br>';
     
    $Longueur = strlen($xml) - strpos($xml,$Search );
    echo $Longueur;
     
    // echo ("</".$Search);
    echo '<br><br><br>';
     
    //deconne à partir de là
    // $Resultat = substr($xml,$IndexDebut,$Longueur);
    // echo $Resultat;
     
    // $Resultats = substr($Resultat,0,strpos($Resultat,"<"));
     
    // echo $Resultats;
     
    //-------------------------------------------------------------------------------------------------------//
     
    // $result  =  simplexml_load_file ( $response );
    // $solution= $result->informationpreleveur[0]-> adresse1;
    // echo $solution;
     
    // $sxml = simplexml_load_file($response );
     
    // echo $sxml->adresse1;
     
    // $response = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $response);
    // $xml = new SimpleXMLElement($response);
    // $body = $xml->xpath('//SBody')[0];
    // $array = json_decode(json_encode((array)$body), TRUE); 
    // print_r($array);
    // ?>

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

Discussions similaires

  1. [Mantis 1.2.3] Ajout d'issue via l'API / SOAP
    Par yrsone dans le forum Autres Logiciels
    Réponses: 1
    Dernier message: 20/10/2010, 14h20
  2. Erreur API compiled et win 7
    Par ikeabp dans le forum Apache
    Réponses: 1
    Dernier message: 14/04/2010, 16h32
  3. [Web Service] erreur connexion soap
    Par mymy2002 dans le forum Bibliothèques et frameworks
    Réponses: 4
    Dernier message: 25/01/2010, 11h26
  4. Erreur "Possible SOAP version mismatch"
    Par MainMa dans le forum Services Web
    Réponses: 0
    Dernier message: 04/10/2009, 01h36
  5. [Web Service] Erreur WSDL, SOAP-ERROR: Parsing WSDL
    Par legide dans le forum Bibliothèques et frameworks
    Réponses: 6
    Dernier message: 14/03/2009, 12h03

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