title: PHP SoapClient fails with - Failed to load external entity
body: <p>I've been trying to use the European Union's website to validate TIN numbers (<a href="https://ec.europa.eu/taxation_customs/tin/tinRequest.html" rel="nofollow">Europa TIN validation website - there is a WSDL available at the bottom of the page)</a></p>
  
  <p>The problem I'm having is that when I try to make a new SoapClient the function fails immediately when building the client. At first I was having a "Failed to load external entity" and I assumed it was because the WSDL has a secure connection. After searching around I found some answers that said that the problem could have to do with the certificate being outdated and the most recent versions of PHP throw errors in that case, so I disabled certificate validation with:</p>
  
  <pre><code>    // Stream context due to certificate problems
      $streamContext = stream_context_create(array(
          'ssl' =&gt; array(
              'verify_peer' =&gt; false,
              'verify_peer_name' =&gt; false,
              'allow_self_signed' =&gt; true
          )
      ));
  </code></pre>
  
  <p>But now I'm getting another error: "failed to open stream: HTTP Request failed! HTTP/1.1 502 Bad Gateway". Any thoughts about how to solve this issue? If I remove "https://" from the link I get the same result as before with the "failed to load external entity" message. </p>
  
  <p>Now here's the real brain picker. If I try to use chrome's extension "Boomerang" to test SOAP calls on the WSDL it works absolutely perfectly, so I have no idea what's wrong here... Anyone can easily try this by attempting to make a soap call in a PHP file. </p>
  
  <p>Here's the full code:</p>
  
  <pre><code>public static function validateTIN($tin) {
      // Stream context due to certificate problems
      $streamContext = stream_context_create(array(
          'ssl' =&gt; array(
              'verify_peer' =&gt; false,
              'verify_peer_name' =&gt; false,
              'allow_self_signed' =&gt; true
          )
      ));
  
      // Create our soap client
      $client = new SoapClient('https://ec.europa.eu/taxation_customs/tin/checkTinService.wsdl', array(
          'exceptions' =&gt; 0,
          'trace' =&gt; 1,
          'connection_timeout' =&gt; 1800,
          'stream_context' =&gt; $streamContext
      ));
  
      dd($client-&gt;__getFunctions());
  
      return true;
  }
  </code></pre>