title: Unable to connect to Magento SOAP API v2 due to "failed to load external entity"
body: <p>I am unable to connect to the Magento SOAP API v2 using PHP. The error that occurs is:</p>
  
  <p><strong>PHP Fatal error:  Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from '<a href="http://www.example.com/index.php/api/v2_soap/index/wsdl/1/" rel="noreferrer">http://www.example.com/index.php/api/v2_soap/index/wsdl/1/</a>' : failed to load external entity "<a href="http://www.example.com/index.php/api/v2_soap/index/wsdl/1/" rel="noreferrer">http://www.example.com/index.php/api/v2_soap/index/wsdl/1/</a>"</strong></p>
  
  <p>As it seems, the WSDL is being loaded, but the external SOAP file which it includes not.</p>
  
  <hr>
  
  <p>PHP connection code:</p>
  
  <pre><code>$client = new SoapClient('http://www.example.com/api/v2_soap?wsdl=1');
  $session = $client-&gt;login('username', 'password');
  </code></pre>
  
  <hr>
  
  <p>Snip from v2_soap?wsdl=1 file:</p>
  
  <pre><code>&lt;service name="MagentoService"&gt;
      &lt;port name="Mage_Api_Model_Server_V2_HandlerPort" binding="typens:Mage_Api_Model_Server_V2_HandlerBinding"&gt;
          &lt;soap:address location="http://www.example.com/index.php/api/v2_soap/index/"/&gt;
      &lt;/port&gt;
  &lt;/service&gt;
  </code></pre>
  
  <hr>
  
  <p>Magento version is <code>1.5.1.0</code>.</p>