Bonjour à tous.
Voila ce qui se passe :
Pour un site web ou j'aimerais implémenter derrière un bouton un service web qui me renverrait une valeur.
j'ai d'abord voulut commencer par des exemples sur le web. malheureusement je me retrouve avec l'erreur suivante :
Fatal error: Class 'SoapServer' not found in C:\Program Files\EasyPHP-5.3.9\www\client_moteur_test.php on line 7
La partie cliente php
la partie 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 <?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 //if (!extension_loaded('soap')){ $clientSOAP = new SoapClient('http://127.0.0.1:8080/HelloYou.wsdl',true); // executer la methode getHello echo $clientSOAP->getHello('Marc','Assin'); ?>
et enfin la partie 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 <?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 = new SoapServer('HelloYou.wsdl'); // ajouter la fonction getHello au serveur $serveurSOAP->addFunction('getHello'); // lancer le serveur if ($_SERVER['REQUEST_METHOD'] == 'POST') { $serveurSOAP->handle(); } else { echo 'désolé, je ne comprends pas les requêtes GET, veuillez seulement utiliser POST'; } function getHello($prenom, $nom) { return 'Hello ' . $prenom . ' ' . $nom; } ?>
voila y'a tout je comprend pas l’élément que j'ai loupé tout en sachant que dans php. ini la dll ( extension=php_soap.dll) est bien libérer
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<?xml version="1.0"?> <!-- partie 1 : Definitions --> <definitions name="HelloYou" targetNamespace="urn:HelloYou" xmlns:typens="urn:HelloYou" 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:HelloYou"> </xsd:schema> </types> <!-- partie 3 : Message --> <message name="getHelloRequest"> <part name="prenom" type="xsd:string"/> <part name="nom" type="xsd:string"/> </message> <message name="getHelloResponse"> <part name="return" type="xsd:string"/> </message> <!-- partie 4 : Port Type --> <portType name="HelloYouPort"> <!-- partie 5 : Operation --> <operation name="getHello"> <input message="typens:getHelloRequest"/> <output message="typens:getHelloResponse"/> </operation> </portType> <!-- partie 6 : Binding --> <binding name="HelloYouBinding" type="typens:HelloYouPort"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="getHello"> <soap:operation soapAction="HelloYouAction"/> <input name="getHelloRequest"> <soap:body use="encoded" namespace="urn:HelloYou" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </input> <output name="getHelloResponse"> <soap:body use="encoded" namespace="urn:HelloYou" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </output> </operation> </binding> <!-- partie 7 : Service --> <service name="HelloYouService"> <documentation>Retourne une phrase simple </documentation> <!-- partie 8 : Port --> <port name="HelloYouPort" binding="typens:HelloYouBinding"> <soap:address location="http://soap.minimonde.org/HelloYou.Server.php5"/> </port> </service> </definitions>
Partager