Bonjour,

Je début complètement et commence tout juste à comprendre comment fonctionne soap.

Voila on m'a donné les éléments suivant pour que je puisse interroger depuis un site ce webservice mais je ne sais pas trop comment le faire fonctionner.


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
 
 
https://wapi.xxxxx.com/wsdl/ApiService.wsdl
 
Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:apis="http://www.example.org/ApiService/">
   <soapenv:Header/>
   <soapenv:Body>
      <apis:checkName>
                 <apis:Name>JohnDoe</apis:Name>
       </apis:checkName>
   </soapenv:Body>
</soapenv:Envelope>
 
 
Response
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Body>
      <availability>1</availability>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

J'ai essayé cela :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
<?php
 
$serverpath="https://wapi.xxxxx.com/wsdl/ApiService.wsdl";
$client = new SoapClient($serverpath);
print_r($client);
 
?>
Il me renvoi :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
SoapClient Object ( [_soap_version] => 1 [sdl] => Resource id #4 )
Ce qui me semble être positif.

J'essai donc ceci:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
<?php
$serverpath="https://wapi.xxxxx.com/wsdl/ApiService.wsdl";
$client = new SoapClient($serverpath);
 
$request = $client->checkName("JohnDoe");
 
print_r($request);
?>
La en revanche ça ne fonctionne pas il me répond:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in D:\model_SOAP\index.php:31 Stack trace: #0 [internal function]: SoapClient->__doRequest('__call('Name', Array) #2 D:\model_SOAP\index.php(31): SoapClient->Name('JohnDoe') #3 {main} thrown in D:\model_SOAP\index.php on line 31
Alors pourquoi ça ne fonctionne pas?
Apparemment je ne peux pas me connecter à l’hôte !!!

Comment faire ? Pouvez vous me mettre sur une piste ?

Merci d'avance.

Pour info je fait mes test en local sur wamp et le fichier wsdl lui est disant.
J'ai bien verifier que php_soap était activé sur wamp.
Je ne suis pas derrière un proxy