Bonjour/bonsoir,
Je suis entrain de créer un projet avec le service web PHP SOAP
et j'ai rencontré ce probleme
Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in C:\wamp\www\client.php:10 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://soap.min...', 'HelloYouAction', 1, 0) #1 [internal function]: SoapClient->__call('getHello', Array) #2 C:\wamp\www\client.php(10): SoapClient->getHello('Marc', 'Assin') #3 {main} thrown in C:\wamp\www\client.php on line 10
Voici les sources des fichiers
client.php
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('HelloYou.wsdl');
// executer la methode getHello
echo $clientSOAP->getHello('Marc','Assin');
?> |
server.php
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
| <?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;
}
?> |
HelloYou.wsdl
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
| <?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> |
Quelqu'un peut m'aider?
Merci d'avance 
NB: Je travaille sur wamp server en utilisant le PHP5.3
Partager