Bonjour,

J'ai déjà effectué une recherche parmi les erreurs de ce type dans les sujets existants et aucune des solutions n'a fonctionné pour moi. Je tente d'implémenter un client web service SOAP en PHP via la classe SOAPClient. J'ai à chaque fois un message "SOAP Fault : Could not connect to host" malgré mes différentes tentatives. Si je fais appel à la méthode __getFunctions() de SOAPClient, j'ai bien une liste des fonctions qui s'affiche. Cependant je ne sais pas si cette liste provient du serveur ou des fichiers WSDL en local (ils ne sont pas récupérés depuis le serveur, on doit les télécharger en local avant utilisation).

Voici le code de la classe :
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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
 
<?php
/**
* Classe pour appels SOAP au serveur de sérialisation NVMS (V2)
*/
require_once("logs.class.php");
 
 
if(!class_exists("SOAPFVMS")) {
  class SOAPFVMS {
    private $wsdl;
    private $type;
    private $log;
    private $debug;
    private $hdebug;
    private $calcul_temps;
    private $lien;
    private $endPointSupportService = "https://ws-support-int-bp.nmvs.eu:8448/WS_SUPPORT_V1/SupportServiceV30";
    private $wsdlRoot;
    private $wsdlSupport = "WS_SUPPORT.wsdl";
 
    /***************************************/
    // 1. FONCTIONS GENERIQUES
    /***************************************/
 
    // Constructeur
    public function __construct($debug = false) {
      if (isset($_SESSION["Temps_Execution"]) && class_exists("TempsGeneration")) {
        $this->calcul_temps = true;
      } else {
        $this->calcul_temps = false;
      }
 
      if($this->calcul_temps) {
        $_SESSION["Temps_Execution"]->Debut_Compter("SOAPFVMS");
      }
 
      $this->debug = $debug;
      $this->hdebug = false;
      // Préparation fonction de log
      $this->log = new LOG("soap_" . date("Ymd_H") . ".log");
 
      if($this->calcul_temps) {
        $_SESSION["Temps_Execution"]->Fin_Compter("SOAPFVMS");
      }
 
      $this->wsdlRoot = dirname(__FILE__) . DIRECTORY_SEPARATOR . "nvms" . DIRECTORY_SEPARATOR . "wsdl" . DIRECTORY_SEPARATOR . "v3" . DIRECTORY_SEPARATOR;
    }
 
    // Destructeur
    public function __destruct() {
      if($this->calcul_temps) {
        $_SESSION["Temps_Execution"]->Debut_Compter("SOAPFVMS");
      }
 
      if($this->calcul_temps)  {
        $_SESSION["Temps_Execution"]->Fin_Compter("SOAPFVMS");
      }
 
      $this->lien="";
    }
 
    // Mode déboggage
    public function debug($etat = true) {
      switch($etat) {
        case true:
          echo "<debug_sql_on>Déboggage SOAP <strong>actif</strong></debug_sql_on>";
          break;
        default:
          echo "<debug_sql_off>Déboggage SOAP <strong>inactif</strong></debug_sql_off>";
      }
 
      $this->debug = $etat;
    }
 
    // Mode Hard Debug : on loggue toute les requetes qui passent
    public function hdebug($etat = true) {
      switch($etat) {
        case true:
          $this->log->logguer("HDA", "Mode Hard Debug ACTIF");
          break;
          $this->log->logguer("HDI", "Mode Hard Debug INACTIF");
        default:
      }
 
      $this->hdebug = $etat;
    }
 
    // Gestion des erreurs
    private function erreur($type, $var1, $var2 = "", $var3 = "") {
      if (isset($_SERVER["REQUEST_URI"]) && !empty($_SERVER["REQUEST_URI"])) {
        $page = $_SERVER["REQUEST_URI"];
      } else {
        $page = "inconnue";
      }
 
      switch($type) {
        case "conn_soap":
          $this->log->logguer("ERR", "Impossible de se connecter au serveur SOAP " . $this->wsdl[$this->type] . ".");
 
          if($this->debug) {
            echo "<debug_sql>Impossible de se connecter au serveur SOAP " . $this->wsdl[$this->type] . "</debug_sql>";
          } else {
            die("<erreur_sql><p>Un problème informatique grave est survenu.</p><p>Laissez cette page ouverte, et contactez le service informatique.</p></erreur_sql>");
          }
          break;
        case "err_soap":
          $this->log->logguer("ERR", "SOAP ERREUR : $var1.");
 
          if($this->debug) {
            echo "<debug_sql>Erreur SOAP : $var1</debug_sql>";
          } else {
            die("<erreur_sql><p>Un problème informatique est survenu.</p><p>Laissez cette page ouverte, et contactez le service informatique.</p></erreur_sql>");
          }
      }
    }
 
    public function ping() {
      $this->wsdl = $this->wsdlRoot . $this->wsdlSupport;
 
      $cert = 'C:/.../cert.p12';
      $pass = 'passPhrase';
 
      /*$ssl = stream_context_create(
        array(
          'ssl' => array(
            'verify_peer'       => false,
            'verify_peer_name'  => false,
            //'local_cert' => $cert,
            //'passphrase' => $pass,
            'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_SERVER
            //'crypto_method' => STREAM_CRYPTO_METHOD_ANY_SERVER
          )
        )
      );
      
      $bool = stream_socket_enable_crypto($ssl, true, STREAM_CRYPTO_METHOD_TLSv1_2_SERVER);*/
 
      /*$this->lien = new SoapClient($this->wsdl, array(
        //'local_cert' => $cert,
        //'passphrase' => $pass,
        //'authentication' => SOAP_AUTHENTICATION_DIGEST,
        'trace'                  => true,
        //'connection_timeout'     => 1,
        //'default_socket_timeout' => 10,
        "exceptions"             => true,
        'soap_version'           => SOAP_1_1,
        //'cache_wsdl'             => WSDL_CACHE_NONE,
        'location' => $this->endPointSupportService,
        //'user_agent' => 'PHP WS',
        //'stream_context' => $ssl
        "stream_context" => stream_context_create(
          array(
            'ssl' => array(
              //'verify_peer'       => false,
              //'verify_peer_name'  => false,
              'local_cert' => $cert,
              'passphrase' => $pass,
              'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_SERVER,
              //'ciphers' => 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384:TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256'
              //'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
            )
          )
        )//,
        //'ssl_method' => SOAP_SSL_METHOD_TLS
      ));*/
      $this->lien = new SoapClient($this->wsdl, array(
        /*'trace'                  => true,
        "exceptions"             => true,
        'soap_version'           => SOAP_1_1,*/
        'local_cert' => $cert,
        'passphrase' => $pass,
        'location' => $this->endPointSupportService
      ));
 
      //curl_setopt(CURLOPT_FRESH_CONNECT, true);
      //curl_setopt(CURLOPT_RETURNTRANSFER, true);
 
 
      //var_dump($bool);
 
      //$this->lien->__setLocation($this->endPointSupportService);
      //stream_socket_enable_crypto($this->lien, 'STREAM_CRYPTO_METHOD_TLSv1_2_SERVER');
 
      //$params = array('urn1:Input' => "Test");
      //$params = array('Input' => "Test");
      //$params = array('urn:SupportPingRequest' => array('Input' => "Test"));
      $params = array('SupportPingRequest' => array('Input' => "Test"));
      //$params = new SoapVar("<urn:SupportPingRequest><urn1:Input>Test</urn1:Input></urn:SupportPingRequest>", XSD_ANYXML);
 
      try {
        //$fnc = $this->lien->__getFunctions();
        //var_dump($fnc);
 
        $result = $this->lien->__soapCall('PingSupport', $params);
        //$result = $this->lien->PingSupport($params);
        //var_dump($result);
      } catch(SoapFault $sf) {
        //echo "REQUEST:\n" . htmlentities($this->lien->__getLastRequest()) . "<br/>";
        //echo "HEADERS:\n" . htmlentities($this->lien->__getLastRequestHeaders()) . "<br/>";
        //echo "RESPONSE:\n" . htmlentities($this->lien->__getLastResponse()) . "<br/>";
        //var_dump($this->lien);
        var_dump($sf);
      }
    }
  }
}
?>
En tentant d'appeler ces web services via SOAPUI, cela fonctionne. J'ai tenté de changer de version de PHP, de version de IIS et même d'utiliser Apache comme serveur Web, rien n'y fait.
Une idée ?