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

Langage PHP Discussion :

Invocation d'un webservice


Sujet :

Langage PHP

  1. #1
    Membre éclairé Avatar de thaundeadboss
    Homme Profil pro
    Développeur COBOL & JAVA
    Inscrit en
    Février 2007
    Messages
    211
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur COBOL & JAVA
    Secteur : Finance

    Informations forums :
    Inscription : Février 2007
    Messages : 211
    Par défaut Invocation d'un webservice
    salut à tous et à toutes.
    j'aimerais savoir comment peut on faire pour invoquer un web services en php et en utiliser le resultats
    des tutoriaux son biensur les bienvenus

  2. #2
    Membre expérimenté
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mai 2009
    Messages
    127
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2009
    Messages : 127
    Par défaut
    Bonjour,

    Suivant les besoins d'appel j'utilise soit fopen (sans parametres envoyés) soit curl (parametres post ou get).

    Après suivant la réponse c'est variable.

    Bon dev

  3. #3
    Membre éclairé Avatar de thaundeadboss
    Homme Profil pro
    Développeur COBOL & JAVA
    Inscrit en
    Février 2007
    Messages
    211
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur COBOL & JAVA
    Secteur : Finance

    Informations forums :
    Inscription : Février 2007
    Messages : 211
    Par défaut
    j'aimerais bien savoir s'il y des tutoriaux concernant l'installation d'un environnement soa dans php et comment l'interaction se passe t elle

  4. #4
    Membre éclairé Avatar de thaundeadboss
    Homme Profil pro
    Développeur COBOL & JAVA
    Inscrit en
    Février 2007
    Messages
    211
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur COBOL & JAVA
    Secteur : Finance

    Informations forums :
    Inscription : Février 2007
    Messages : 211
    Par défaut
    si ce que j'ai donné comme explocation n'est pas claire .
    je crois que je dois réaliser un client en php qui consomme un web service

  5. #5
    Membre émérite

    Profil pro
    Inscrit en
    Juin 2004
    Messages
    772
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations forums :
    Inscription : Juin 2004
    Messages : 772
    Par défaut
    Regarde de ce côté :

    Librairie SOAP

    Ca marche si le webservice est compatible SOAP... Pour le reste, ce serait bien d'être sûr de ce que ton prof te demande...

  6. #6
    Membre éclairé Avatar de thaundeadboss
    Homme Profil pro
    Développeur COBOL & JAVA
    Inscrit en
    Février 2007
    Messages
    211
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur COBOL & JAVA
    Secteur : Finance

    Informations forums :
    Inscription : Février 2007
    Messages : 211
    Par défaut
    j'ai essayé avec ce lien mais je n'arrive pas a comprendre.
    dans un premier momoent j'ai fait un web service à partir d'un POJO je l'ai archiver et deployé dans tomcat-axis2
    j'ai programmé le client(enfin j'ai juste repris le codes du client dans la pâge du lien j'espere que client veut dire la meme chose en anglais)

    http://www.scottnichol.com/nusoapintro.htm

    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
    // Pull in the NuSOAP code
    require_once('./lib/nusoap.php');
    // Create the client instance
    $client = new soapclient('http://localhost:8080/axis2/services/Authentification?wsdl');
    // Call the SOAP method
    $result = $client->call('auth', array('mat' => '114024','mdp' => '123456'));
    // Display the result
    print_r($result);
    if ($client->fault) {
    echo'<p><b>Fault: ';
    print_r($result);
    echo'</b></p>';
    } else {
    // Check for errors
    $err = $client->getError();
    if ($err) {
    // Display the error
    echo'<p><b>Error: ' . $err . '</b></p>';
    } else {
    // Display the result
    print_r($result);
    }
    }
    et voici le wsdl de mon service web
    Code XML : 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
     
    <wsdl:definitions targetNamespace="http://ws.apache.org/axis2">
    <wsdl:documentation>Authentification</wsdl:documentation>
    −
     <wsdl:types>
    −
     <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://ws.apache.org/axis2">
    −
     <xs:complexType name="Exception">
    −
     <xs:sequence>
    <xs:element minOccurs="0" name="Exception" nillable="true" type="xs:anyType"/>
    </xs:sequence>
    </xs:complexType>
    −
     <xs:element name="Exception">
    −
     <xs:complexType>
    −
     <xs:sequence>
    <xs:element minOccurs="0" name="Exception" nillable="true" type="ns:Exception"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    −
     <xs:element name="auth">
    −
     <xs:complexType>
    −
     <xs:sequence>
    <xs:element minOccurs="0" name="mat" nillable="true" type="xs:string"/>
    <xs:element minOccurs="0" name="mdp" nillable="true" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    −
     <xs:element name="authResponse">
    −
     <xs:complexType>
    −
     <xs:sequence>
    <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    </wsdl:types>
    −
     <wsdl:message name="authRequest">
    <wsdl:part name="parameters" element="ns:auth"/>
    </wsdl:message>
    −
     <wsdl:message name="authResponse">
    <wsdl:part name="parameters" element="ns:authResponse"/>
    </wsdl:message>
    −
     <wsdl:message name="Exception">
    <wsdl:part name="parameters" element="ns:Exception"/>
    </wsdl:message>
    −
     <wsdl:portType name="AuthentificationPortType">
    −
     <wsdl:operation name="auth">
    <wsdl:input message="ns:authRequest" wsaw:Action="urn:auth"/>
    <wsdl:output message="ns:authResponse" wsaw:Action="urn:authResponse"/>
    <wsdl:fault message="ns:Exception" name="Exception" wsaw:Action="urn:authException"/>
    </wsdl:operation>
    </wsdl:portType>
    −
     <wsdl:binding name="AuthentificationSoap11Binding" type="ns:AuthentificationPortType">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    −
     <wsdl:operation name="auth">
    <soap:operation soapAction="urn:auth" style="document"/>
    −
     <wsdl:input>
    <soap:body use="literal"/>
    </wsdl:input>
    −
     <wsdl:output>
    <soap:body use="literal"/>
    </wsdl:output>
    −
     <wsdl:fault name="Exception">
    <soap:fault use="literal" name="Exception"/>
    </wsdl:fault>
    </wsdl:operation>
    </wsdl:binding>
    −
     <wsdl:binding name="AuthentificationSoap12Binding" type="ns:AuthentificationPortType">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    −
     <wsdl:operation name="auth">
    <soap12:operation soapAction="urn:auth" style="document"/>
    −
     <wsdl:input>
    <soap12:body use="literal"/>
    </wsdl:input>
    −
     <wsdl:output>
    <soap12:body use="literal"/>
    </wsdl:output>
    −
     <wsdl:fault name="Exception">
    <soap12:fault use="literal" name="Exception"/>
    </wsdl:fault>
    </wsdl:operation>
    </wsdl:binding>
    −
     <wsdl:binding name="AuthentificationHttpBinding" type="ns:AuthentificationPortType">
    <http:binding verb="POST"/>
    −
     <wsdl:operation name="auth">
    <http:operation location="Authentification/auth"/>
    −
     <wsdl:input>
    <mime:content type="text/xml" part="auth"/>
    </wsdl:input>
    −
     <wsdl:output>
    <mime:content type="text/xml" part="auth"/>
    </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
    −
     <wsdl:service name="Authentification">
    −
     <wsdl:port name="AuthentificationHttpSoap11Endpoint" binding="ns:AuthentificationSoap11Binding">
    <soap:address location="http://10.64.5.76:8080/axis2/services/Authentification.AuthentificationHttpSoap11Endpoint"/>
    </wsdl:port>
    −
     <wsdl:port name="AuthentificationHttpSoap12Endpoint" binding="ns:AuthentificationSoap12Binding">
    <soap12:address location="http://10.64.5.76:8080/axis2/services/Authentification.AuthentificationHttpSoap12Endpoint"/>
    </wsdl:port>
    −
     <wsdl:port name="AuthentificationHttpEndpoint" binding="ns:AuthentificationHttpBinding">
    <http:address location="http://10.64.5.76:8080/axis2/services/Authentification.AuthentificationHttpEndpoint"/>
    </wsdl:port>
    </wsdl:service>
    </wsdl:definitions>

    Si quelqu'un pourrait m'aider je lui en serait reconnaisant

  7. #7
    Membre émérite

    Profil pro
    Inscrit en
    Juin 2004
    Messages
    772
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations forums :
    Inscription : Juin 2004
    Messages : 772
    Par défaut
    Et qu'est-ce que tu obtiens quand tu appelles ta page client ?

    Dans ta wsdl, il y a une adresse spécifiée à la fin :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <soap:address location="http://10.64.5.76:8080/axis2/services/Authentification.AuthentificationHttpSoap11Endpoint"/>
    Si tu héberges toi-même le webservice, l'adresse 10.64.5.76 n'est plus valable, tu dois donc changer cela dans ta WSDL, par 127.0.0.1:8080 si tu es bien sur le port 8080...

    Tu peux faire de même pour les 2 adresses en dessous....

  8. #8
    Membre éclairé Avatar de thaundeadboss
    Homme Profil pro
    Développeur COBOL & JAVA
    Inscrit en
    Février 2007
    Messages
    211
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur COBOL & JAVA
    Secteur : Finance

    Informations forums :
    Inscription : Février 2007
    Messages : 211
    Par défaut
    j'ai ajouter le endpoint et sa donne de nouveau les erreurs suivante:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    Warning: SoapClient::SoapClient(http://10.64.5.76:8080/axis2/services/Authentification.AuthentificationHttpSoap11Endpoint) [function.SoapClient-SoapClient]: failed to open stream: HTTP request failed! HTTP/1.1 500 Erreur Interne de Servlet in C:\xampp\htdocs\TWS\tstws.php on line 5
     
    Warning: SoapClient::SoapClient() [function.SoapClient-SoapClient]: I/O warning : failed to load external entity "http://10.64.5.76:8080/axis2/services/Authentification.AuthentificationHttpSoap11Endpoint" in C:\xampp\htdocs\TWS\tstws.php on line 5
     
    Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://10.64.5.76:8080/axis2/services/Authentification.AuthentificationHttpSoap11Endpoint' in C:\xampp\htdocs\TWS\tstws.php:5 Stack trace: #0 C:\xampp\htdocs\TWS\tstws.php(5): SoapClient->SoapClient('http://10.64.5....') #1 {main} thrown in C:\xampp\htdocs\TWS\tstws.php on line 5

  9. #9
    Membre émérite

    Profil pro
    Inscrit en
    Juin 2004
    Messages
    772
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations forums :
    Inscription : Juin 2004
    Messages : 772
    Par défaut
    Tu as ajouté ou tu as remplacé ? Il faut remplacer la ligne dans la ligne que j'ai citée par localhost:8080.

    A ta place je commenterais les 2 lignes en-dessous pour obtenir ça :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    <wsdl:service name="Authentification">
        <wsdl:port name="AuthentificationHttpSoap11Endpoint" binding="ns:AuthentificationSoap11Binding">
            <soap:address location="http://localhost:8080/axis2/services/Authentification.AuthentificationHttpSoap11Endpoint"/>
        </wsdl:port>
         <!-- wsdl:port name="AuthentificationHttpSoap12Endpoint" binding="ns:AuthentificationSoap12Binding">
            <soap12:address location="http://10.64.5.76:8080/axis2/services/Authentification.AuthentificationHttpSoap12Endpoint"/>
        </wsdl:port>
        <wsdl:port name="AuthentificationHttpEndpoint" binding="ns:AuthentificationHttpBinding">
            <http:address location="http://10.64.5.76:8080/axis2/services/Authentification.AuthentificationHttpEndpoint"/>
        </wsdl:port -->
    </wsdl:service>
    L'erreur indique que la page qui expose le webservicve est inaccessible.

    Tu peux copier ce que tu obtiens quand tu tapes l'url de la wsdl dans ton navigateur ?

  10. #10
    Membre éclairé Avatar de thaundeadboss
    Homme Profil pro
    Développeur COBOL & JAVA
    Inscrit en
    Février 2007
    Messages
    211
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur COBOL & JAVA
    Secteur : Finance

    Informations forums :
    Inscription : Février 2007
    Messages : 211
    Par défaut
    je relance mon topic souhaitant que mon sauveur est dans les parages

  11. #11
    Membre Expert
    Avatar de Thes32
    Homme Profil pro
    Développeur PHP, .Net, T-SQL
    Inscrit en
    Décembre 2006
    Messages
    2 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations professionnelles :
    Activité : Développeur PHP, .Net, T-SQL

    Informations forums :
    Inscription : Décembre 2006
    Messages : 2 379

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

Discussions similaires

  1. Invocation de webService en java
    Par achaal dans le forum Services Web
    Réponses: 0
    Dernier message: 09/09/2014, 19h01
  2. Réponses: 4
    Dernier message: 29/05/2010, 11h01
  3. Réponses: 0
    Dernier message: 03/07/2009, 10h43
  4. [Axis2] Erreur d'invocation d'un WebService
    Par Oui-Oui MB dans le forum Services Web
    Réponses: 1
    Dernier message: 24/05/2007, 14h42
  5. WebService Google sur builder 5?
    Par billuh dans le forum C++Builder
    Réponses: 3
    Dernier message: 19/11/2002, 20h43

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