[edit] : pb résolu je n'avait pas changé l'adresse du wsdl. Par contre ma deuxième question reste d'acutalité.
Bonsoir à tous,
Je vers vous car j'ai deux petites questions.
Je tiens à préciser que je commence a peine a m'intéresser aux webservices. Ce matin seulement.
Premièrement un concernant un bugs. Ça marche pourtant très bien sur mon serveur local par contre sur mon serveur pas du tout. Je pense avoir bien vérifier la config de mon serveur mais j'en suis pas certains.
Deuxièmement est il possible de définir plusieurs méthodes dans un WSDL ou faut il faire un WSDL par méthode?
Voila mon code d'erreur
Et mes codes sources:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in /testmail/client_contacter.php:10 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...", 'http://localhos...', 'contacterAction', 1, 0) #1 [internal function]: SoapClient->__call('contacter', Array) #2 /testmail/client_contacter.php(10): SoapClient->contacter('de ROCQUIGNY', 'Hubert', 'hubert.derocqui...', 'Methode contact...') #3 {main} thrown in /testmail/client_contacter.php on line 10
client_contacter.php
server_contacter.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 <?php // première étape : désactiver le cache lors de la phase de test ini_set("soap.wsdl_cache_enabled", "0"); // lier le client au fichier WSDL $clientSOAP = new SoapClient('appMobile_contacter.wsdl'); // executer la methode contacter echo $clientSOAP->contacter('2rock','Hub', 'derock@test.fr', 'Methode contacter.'); ?>
appMobile_contacter.wsdl
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 <?php // première étape : désactiver le cache lors de la phase de test ini_set("soap.wsdl_cache_enabled", "0"); // on indique au serveur à quel fichier de description il est lié $serveurSOAP_contacter = new SoapServer('appMobile_contacter.wsdl'); // ajouter la fonction ajoutCandidature et contacter au serveur $serveurSOAP_contacter->addFunction('contacter'); // lancer le serveur if ($_SERVER['REQUEST_METHOD'] == 'POST') { $serveurSOAP_contacter->handle(); } else { echo 'désolé, je ne comprends pas les requêtes GET, veuillez seulement utiliser POST'; } function contacter($nom, $prenom, $email, $message) { $mailto = 'hub2rock@yopmail.com'; $subject = '[SEPEFREI] - Demande d\'information'; try { sendMail($nom, $prenom, $email, $message, $mailto, $subject); $ret = 'OK'; } catch(Exception $e) { $ret = 'KO'; } return $ret; } ?>
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<?xml version="1.0"?> <!-- partie 1 : Definitions --> <definitions name="appMobile" targetNamespace="urn:appMobile" xmlns:typens="urn:appMobile" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"> <!-- partie 2 : Types--> <types> <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:appMobile"> </xsd:schema> </types> <!-- partie 3 : Message --> <message name="contacterRequest"> <part name="nom" type="xsd:string"/> <part name="prenom" type="xsd:string"/> <part name="email" type="xsd:string"/> <part name="message" type="xsd:string"/> </message> <message name="contacterResponse"> <part name="return" type="xsd:string"/> </message> <!-- partie 4 : Port Type --> <portType name="contacterPort"> <!-- partie 5 : Operation --> <operation name="contacter"> <input message="typens:contacterRequest"/> <output message="typens:contacterResponse"/> </operation> </portType> <!-- partie 6 : Binding --> <binding name="contacterBinding" type="typens:contacterPort"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="contacter"> <soap:operation soapAction="contacterAction"/> <input name="contacterRequest"> <soap:body use="encoded" namespace="urn:appMobile" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </input> <output name="contacterResponse"> <soap:body use="encoded" namespace="urn:appMobile" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </output> </operation> </binding> <!-- partie 7 : Service --> <service name="contacterService"> <documentation>Envoi un mail de contact a SEPEFREI.</documentation> <!-- partie 8 : Port --> <port name="contacterPort" binding="typens:contacterBinding"> <soap:address location="http://localhost/WebService/server_contacter.php"/> <!-- modifier ce chemin vers server.php --> </port> </service> </definitions>
Partager