Search code examples
magentomagento-soap-api

Using Soap in magento


I'm trying to follow the information about how to use soap in magento, but always get same message in error.log

If any one experience something similar, that could give me some tip, it will be welcome.

"PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://www.site.com/index.php/api/?wsdl' : failed to load external entity "http://www.site.com/index.php/api/?wsdl"\n in /var/www/test.php on line 1"

$client = new SoapClient('http://www.site.com/api/?wsdl');

$session = $client->login('apiUser', 'apiKey');

$result = $client->call($session, 'somestuff.method');
$result = $client->call($session, 'somestuff.method', 'arg1');
$result = $client->call($session, 'somestuff.method', array('arg1', 'arg2', 'arg3'));
$result = $client->multiCall($session, array(
    array('somestuff.method'),
    array('somestuff.method', 'arg1'),
    array('somestuff.method', array('arg1', 'arg2'))
));


// If you don't need the session anymore
$client->endSession($session);

Solution

  • where you have www.site.com in your SOAP code, replace it with localhost or whatever the correct URL is for your server. You'll also need to replace somestuff.method with real objects and methods as per the Magento documentation