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 :

[Web Service][SOAP] La réponse obtenue est le code wsdl


Sujet :

Bibliothèques et frameworks PHP

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Septembre 2003
    Messages
    31
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2003
    Messages : 31
    Points : 29
    Points
    29
    Par défaut [Web Service][SOAP] La réponse obtenue est le code wsdl
    Bonjour à tous,

    Voilà, j'utilise la librairie nusoap 0.7.3 (qui est la dernière me semble-il) et j'ai un petit souci.

    Je travaille sur deux machines différentes et avec deux fichiers php (un serveur qui génére le wsdl et le client qui appel une fonction : MaFonction) sont identique.

    Sur le premier serveur, j'obtiens le résultat escompté :

    Requete:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    POST /webservices/mon_ws.php HTTP/1.0
    Host: dev1.chezmoi.net
    User-Agent: NuSOAP/0.7.3 (1.114)
    Content-Type: text/xml; charset=ISO-8859-1
    SOAPAction: "urn:MonWSDL#MaFonction"
    Content-Length: 529
     
    <?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:MonWSDL"><SOAP-ENV:Body><tns:MaFonction xmlns:tns="urn:MonWSDL"><votre_nom xsi:type="xsd:string">Bridou</votre_nom></tns:MaFonction></SOAP-ENV:Body></SOAP-ENV:Envelope>
    Reponse:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    HTTP/1.1 200 OK
    Date: Wed, 27 Feb 2008 08:29:39 GMT
    Server: Apache/2.0.54 (Debian GNU/Linux) PHP/4.3.10-22 mod_ssl/2.0.54 OpenSSL/0.9.7e
    X-Powered-By: PHP/4.3.10-22
    X-SOAP-Server: NuSOAP/0.7.3 (1.114)
    Content-Length: 454
    Connection: close
    Content-Type: text/xml; charset=ISO-8859-1
     
    <?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:MaFonctionResponse xmlns:ns1="urn:MonWSDL"><return xsi:type="xsd:string">Salut Bridou</return></ns1:MaFonctionResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>


    Tandis que sur le second serveur la requête est toujours correcte mais la réponse renvoyée est en fait la définition du wsdl purement et simplement :

    Requete:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    POST /soap/mon_ws.php?wsdl HTTP/1.0
    Host:  monIP:3128
    User-Agent: NuSOAP/0.7.3 (1.114)
    Content-Type: text/xml; charset=ISO-8859-1
    SOAPAction: "urn:MonWSDL#MaFonction"
    Content-Length: 529
     
    <?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:MonWSDL"><SOAP-ENV:Body><tns:MaFonction xmlns:tns="urn:MonWSDL"><votre_nom xsi:type="xsd:string">Bridou</votre_nom></tns:MaFonction></SOAP-ENV:Body></SOAP-ENV:Envelope>
    Reponse:
    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
     
    HTTP/1.1 200 OK
    Date: Wed, 27 Feb 2008 08:40:07 GMT
    Server: Apache
    Content-Length: 3055
    Connection: close
    Content-Type: text/xml; charset=ISO-8859-1
     
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:MonWSDL" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:MonWSDL">
    <types>
    <xsd:schema targetNamespace="urn:MonWSDL"
    >
     <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
     <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
     <xsd:complexType name="Personne">
      <xsd:all>
       <xsd:element name="prenom" type="xsd:string"/>
       <xsd:element name="age" type="xsd:int"/>
      </xsd:all>
     </xsd:complexType>
     <xsd:complexType name="TypeRetour">
      <xsd:all>
       <xsd:element name="retour_1" type="xsd:string"/>
       <xsd:element name="retour_2" type="xsd:string"/>
       <xsd:element name="retour_3" type="xsd:string"/>
      </xsd:all>
     </xsd:complexType>
    </xsd:schema>
    </types>
    <message name="MaFonctionRequest">
      <part name="votre_nom" type="xsd:string" /></message>
    <message name="MaFonctionResponse">
      <part name="return" type="xsd:string" /></message>
    <message name="MaSecondeFonctionRequest">
      <part name="var_personne" type="tns:Personne" /></message>
    <message name="MaSecondeFonctionResponse">
      <part name="return" type="tns:TypeRetour" /></message>
    <portType name="MonWSDLPortType">
      <operation name="MaFonction">
        <documentation>Fonction qui dit salut !</documentation>
        <input message="tns:MaFonctionRequest"/>
        <output message="tns:MaFonctionResponse"/>
      </operation>
      <operation name="MaSecondeFonction">
        <documentation>Greet a person entering the sweepstakes</documentation>
        <input message="tns:MaSecondeFonctionRequest"/>
        <output message="tns:MaSecondeFonctionResponse"/>
      </operation>
    </portType>
    <binding name="MonWSDLBinding" type="tns:MonWSDLPortType">
      <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
      <operation name="MaFonction">
        <soap:operation soapAction="urn:MonWSDL#MaFonction" style="rpc"/>
        <input><soap:body use="encoded" namespace="urn:MonWSDL" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
        <output><soap:body use="encoded" namespace="urn:MonWSDL" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
      </operation>
      <operation name="MaSecondeFonction">
        <soap:operation soapAction="urn:MonWSDL#MaSecondeFonction" style="rpc"/>
        <input><soap:body use="encoded" namespace="urn:MonWSDL" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
        <output><soap:body use="encoded" namespace="urn:MonWSDL" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
      </operation>
    </binding>
    <service name="MonWSDL">
      <port name="MonWSDLPort" binding="tns:MonWSDLBinding">
        <soap:address location="http://monIP:3128/soap/mon_ws.php?wsdl"/>
      </port>
    </service>
    </definitions>
    Ce n'est pas moi qui est configuré les machines mais la différence notable que j'ai souligné est la suivante :
    Serveur 1 : Apache 2 + Php4
    Serveur 2 : Apache 2 + Php5 (et j'utilise un port différent : 3128)

    Au niveau du code je sais donc que c'est correct (puisque les fichiers sont identiques sur chaque serveur). De plus si j'essaie d'accéder à une fonction inexistante, j'obtiens bien une erreur sur les deux serveurs. Donc c'est vraiment la réponse de soap qui coince.

    Auriez vous des pistes à m'indiquer pour que je vérifie à quel niveau cela peut survenir ? Est-il possible que la configuration de php ou apache bloque la réponse du nusoap ?

    Car en regardant l'entête de la réponse du second serveur il manque bien :
    X-SOAP-Server: NuSOAP/0.7.3 (1.114)

    Merci pour votre aide !

    Bonne journée
    Bridou

  2. #2
    Membre averti
    Homme Profil pro
    Développeur Web
    Inscrit en
    Avril 2004
    Messages
    318
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Avril 2004
    Messages : 318
    Points : 362
    Points
    362
    Par défaut
    A mon avis c'est une erreur côté serveur php et/ou la librairie NuSOAP. Je l'ai jamais utilisée, j'ai la chance de bosser que sur PHP5.

    Donc je peux pas trop t'aider, mais donne nous quand même ton code php côté serveur s'il te plait

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Septembre 2003
    Messages
    31
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2003
    Messages : 31
    Points : 29
    Points
    29
    Par défaut
    Salut,

    Voici le code du serveur :

    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
     
    <?php
    // Pull in the NuSOAP code
    require_once('nusoap.php');
     
    // Create the server instance
    $server = new soap_server();
     
    // Initialize WSDL support
    $server->configureWSDL('MonWSDL', 'urn:MonWSDL', "http://monIP:3128/soap/mon_ws.php?wsdl");
     
    // Register the method to expose
    $server->register('MaFonction',                // method name
        array('votre_nom' => 'xsd:string'),        // input parameters
        array('return' => 'xsd:string'),      // output parameters
        'urn:MonWSDL',                      // namespace
        'urn:MonWSDL#MaFonction',                // soapaction
        'rpc',                                // style
        'encoded',                            // use
        'Fonction qui dit salut !'            // documentation
    );
     
    // Define the method as a PHP function
    function MaFonction($votre_nom) {
            return 'Salut ' . $votre_nom;
    }
     
    $server->wsdl->addComplexType(
        'Personne',
        'complexType',
        'struct',
        'all',
        '',
        array(
            'prenom' => array('name' => 'prenom', 'type' => 'xsd:string'),
            'age' => array('name' => 'age', 'type' => 'xsd:int')
        )
    );
    $server->wsdl->addComplexType(
        'TypeRetour',
        'complexType',
        'struct',
        'all',
        '',
        array(
            'retour_1' => array('name' => 'retour_1', 'type' => 'xsd:string'),
            'retour_2' => array('name' => 'retour_2', 'type' => 'xsd:string'),
            'retour_3' => array('name' => 'retour_3', 'type' => 'xsd:string')
        )
    );
    // Register the method to expose
    $server->register('MaSecondeFonction',                    // method name
        array('var_personne' => 'tns:Personne'),          // input parameters
        array('return' => 'tns:TypeRetour'),    // output parameters
        'urn:MonWSDL',                         // namespace
        'urn:MonWSDL#MaSecondeFonction',                   // soapaction
        'rpc',                                    // style
        'encoded',                                // use
        'Greet a person entering the sweepstakes'        // documentation
    );
    // Define the method as a PHP function
    function MaSecondeFonction($var_personne) {
     
        $var_tmp = 'Salut ' . $var_personne['prenom'] .'<br>'.
                    '. Tu as ' . $var_personne['age'] .' ans';
     
        return array(
                    'retour_1' => "Contenu retour 1",
                    'retour_2' => "Contenu retour 2",
                    'retour_3' => $var_tmp
                    );
    }
     
     
    // Use the request to (try to) invoke the service
    $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
    $server->service($HTTP_RAW_POST_DATA);
    ?>
    Et puis le client comme ça on a tout :
    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
     
    <?php
    // Pull in the NuSOAP code
    require_once('nusoap.php');
     
    // Create the client instance
    $client = new nusoap_client('http://monIP:3128/soap/mon_ws.php?wsdl', true);
     
    // Check for an error
    $err = $client->getError();
    if ($err) {
        // Display the error
        echo '<h2>Erreur</h2><pre>' . $err . '</pre>';
        // At this point, you know the call that follows will fail
    }
     
     
    // Call the SOAP method
    $result = $client->call('MaFonction', array('votre_nom' => 'Bridou'));
     
    // Check for a fault
    if ($client->fault) {
        echo '<h2>Erreur</h2><pre>';
        print_r($result);
        echo '</pre>';
    } else {
        // Check for errors
        $err = $client->getError();
        if ($err) {
            // Display the error
            echo '<h2>Erreur</h2><pre>' . $err . '</pre>';
        } else {
            // Display the result
            echo '<h2>Resultat de MaFonction</h2><pre>';
            print_r($result);
        echo '</pre>';
        }
    }
    // Display the request and response
    echo '<h2>Requete</h2>';
    echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
    echo '<h2>Reponse</h2>';
    echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
     
    // Call the SOAP method
    $parametres = array('prenom' => 'Mickaël', 'age' => 24);
    $result = $client->call('MaSecondeFonction', array('var_personne' => $parametres) );
     
    // Check for a fault
    if ($client->fault) {
        echo '<h2>Erreur</h2><pre>';
        print_r($result);
        echo '</pre>';
    } else {
        // Check for errors
        $err = $client->getError();
        if ($err) {
            // Display the error
            echo '<h2>Erreur</h2><pre>' . $err . '</pre>';
        } else {
            // Display the result
            echo '<h2>Resultat de MaSecondeFonction</h2><pre>';
            print_r($result);
        echo '</pre>';
        }
    }
     
     
     
    // Display the request and response
    echo '<h2>Requete</h2>';
    echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
    echo '<h2>Reponse</h2>';
    echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
     
    // Display the debug messages
    echo '<h2>Debug</h2>';
    echo '<pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
     
    ?>
    Même sur le forum de cette librairie je ne trouve rien

    Enfin merci d'essayer de m'aider !

    A+

  4. #4
    Membre averti
    Homme Profil pro
    Développeur Web
    Inscrit en
    Avril 2004
    Messages
    318
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Avril 2004
    Messages : 318
    Points : 362
    Points
    362
    Par défaut
    Effectivement c'est bizarre...
    Sans connaitre NuSOAP c'est pas simple ^^

    Donc c'est bien avec PHP5 que ca ne fonctionne pas ?

    Ce qui me trouble mais c'est peut etre normal avec ta façon c'est dans ton WSDL :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <soap:address location="http://monIP:3128/soap/mon_ws.php?wsdl"/>
    Ca devrait pointer sur le serveur en lui même, pas sur le WSDL. Mais bon comme il est créée à la volée, j'ai jamais fait ca non plus... Je sais pas

    Bon courage !

  5. #5
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Septembre 2003
    Messages
    31
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2003
    Messages : 31
    Points : 29
    Points
    29
    Par défaut
    Je ne sais pas si c'est la faute de PHP5 mais c'est la différence notable au niveau de la configuration.

    Et comme tu le soulignes :
    <soap:address location="http://monIP:3128/soap/mon_ws.php?wsdl"/>

    Permet d'accéder au wsdl généré à la volée donc c'est correct (du moins ca fonctionne sur un des deux serveurs

    Je vais voir s'il n'est pas plus simple d'utiliser la fonctionnalité soap de php5 car la librairie m'était utile sous PHP4.

    Sais-tu si on peut générer un wsdl à la volée avec soap de php5 ?

    Merci

  6. #6
    Membre averti
    Homme Profil pro
    Développeur Web
    Inscrit en
    Avril 2004
    Messages
    318
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Avril 2004
    Messages : 318
    Points : 362
    Points
    362
    Par défaut
    Il existe des scripts qui peuvent le faire, mais rien de natif côté php. Mais tu peux essayer de simplement recopier le WSDL généré sur l'autre serveur, et d'en faire ton fichier .wsdl ^^

    En tout cas les fonctionalités SOAP de php sont simples. Une fois que t'as fait ton WSDL, tu es tranquille.

Discussions similaires

  1. Web service SOAP : Formatage de la réponse XML
    Par casawi dans le forum Services Web
    Réponses: 1
    Dernier message: 04/06/2017, 19h28
  2. affichage de la réponse d'un web service SOAP !
    Par ImmoTPA dans le forum Services Web
    Réponses: 4
    Dernier message: 01/01/2015, 16h51
  3. Web Service - lecture de réponse SOAP "élégante"
    Par Leelith dans le forum Services Web
    Réponses: 2
    Dernier message: 23/06/2013, 22h01
  4. web services, soap et compression.
    Par renaudjuif dans le forum Langage
    Réponses: 6
    Dernier message: 31/07/2006, 15h44
  5. [Web Service] [SOAP] Envoie requete
    Par _beber85 dans le forum JDBC
    Réponses: 1
    Dernier message: 08/06/2006, 09h31

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