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
Version imprimable
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
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:mrgreen:
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
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
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... :mouarf:
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
et voici le wsdl de mon service webCode:
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); } }
Code:
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
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 :
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...Code:<soap:address location="http://10.64.5.76:8080/axis2/services/Authentification.AuthentificationHttpSoap11Endpoint"/>
Tu peux faire de même pour les 2 adresses en dessous....
j'ai ajouter le endpoint et sa donne de nouveau les erreurs suivante:
Code:
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
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 :
L'erreur indique que la page qui expose le webservicve est inaccessible.Code:
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>
Tu peux copier ce que tu obtiens quand tu tapes l'url de la wsdl dans ton navigateur ?
je relance mon topic souhaitant que mon sauveur est dans les parages