title: Error WSDL: SOAP-ERROR: Parsing WSDL: Couldn't load from
body: <p>My problem is very common. I read almost all topics on stackoverflow about this issue, but still can not do thing work. My code is :</p>
  
  <pre><code>ini_set("soap.wsdl_cache", "0");
  ini_set("soap.wsdl_cache_enabled", "0");
  $proxy = new SoapClient('http://Myhostname/api/soap?wsdl');
  </code></pre>
  
  <p>I had this error : </p>
  
  <pre><code>Error WSDL: SOAP-ERROR: Parsing WSDL: Couldn't load from 
  'http://Myhostname/api/soap?wsdl' : failed to load external entity 
  "http://Myhostname/api/soap?wsdl"
  </code></pre>
  
  <p>In the browser the URL </p>
  
  <pre><code>http://Myhostname/api/soap?wsdl
  </code></pre>
  
  <p>works great (returns an xml response)</p>
  
  <p>I try this code to see if PHP can reach this URL :</p>
  
  <pre><code>if (file_get_contents('http://Myhostname/api/soap?wsdl') === false) {
      echo "ERROR: file_get_contents &lt;br/&gt;";
  }
  </code></pre>
  
  <p>It displays me my error "ERROR: file_get_contents", so it does not work. On the forums I saw that to solve this problem I must add hostname into OS "hosts" file. So I did it. In my hosts file I added this line
      127.0.0.1     Myhostname</p>
  
  <p>But it still does not work. Then I changed URL in my code to</p>
  
  <pre><code>http://localhost/Myhostname/api/soap?wsdl
  </code></pre>
  
  <p>but it does not work either.</p>
  
  <p>I tried another solution I found on the internet. For some people it worked. In my URL I changed '?' character to '.'. So my new URL became</p>
  
  <pre><code>http://localhost/Myhostname/api/soap.wsdl
  </code></pre>
  
  <p>but it does not work either. </p>
  
  <p>I saw <a href="http://www.php.net/manual/fr/soapclient.soapclient.php" rel="noreferrer">official SOAP doc</a>! And tried to create SoapClient object in different way (with options like 'proxy_host' and 'proxy_port'). But this did not help me.</p>
  
  <p>It's my second day I try to solve this problem, but I can not. I am doing my internship, I do not have a lot of experience, so maybe I did not try solutions I found correctly. Maybe someone can help. I would be very pleased.</p>