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.example.com/index.php/api/v2_soap/index/wsdl/1/' : failed to load external entity "http://www.example.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.example.com/api/v2_soap?wsdl=1');
$session = $client->login('username', 'password');
Snip from v2_soap?wsdl=1 file:
<service name="MagentoService">
<port name="Mage_Api_Model_Server_V2_HandlerPort" binding="typens:Mage_Api_Model_Server_V2_HandlerBinding">
<soap:address location="http://www.example.com/index.php/api/v2_soap/index/"/>
</port>
</service>
Magento version is 1.5.1.0
.
This problem is caused by the server not being able to access the file from the local machine. So the possible cause could've been the DNS server or /etc/hosts, but it was actually a .htaccess file blocking any hosts except from our development computers. This resulted in a 403 Forbidden error, which resulted in the SOAP error and so on..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With