Unable to connect to Magento SOAP API v2 due to “failed to load external entity”-Collection of common programming errors

I am unable to connect to the Magento SOAP API v2 using PHP. The error that occurs is:

PHP Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn’t load from ‘http://www.mydomain.com/index.php/api/v2_soap/index/wsdl/1/’ : failed to load external entity “http://www.mydomain.com/index.php/api/v2_soap/index/wsdl/1/”

As it seems, the WSDL is being loaded, but the external SOAP file which it includes not.

PHP connection code:

$client = new SoapClient('http://www.domain.com/api/v2_soap?wsdl=1');
$session = $client->login('username', 'password');

Snip from v2_soap?wsdl=1 file:


    
        
    

Magento version is 1.5.1.0, official documentation can be found at http://www.magentocommerce.com/wiki/doc/webservices-api/introduction.

Any help would be great!