Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento API call for getting products information

Tags:

php

soap

magento

I used the below code to get products details from a magento store from my localhost

$proxy = new SoapClient('http://domain.com/magento/index.php/api/soap/?wsdl');

$sessionId = $proxy->login('username', 'apikey');
$filters = array(
    'sku' => array('like'=>'test%')
);

$products = $proxy->call($sessionId, 'product.list', array($filters));

var_dump($products);

It works on my localhost machine but not on server. But soap configuration is enabled in server. Below is the error message

" SOAP-ERROR: Parsing WSDL: Couldn't find <definitions> in "

I got corresponding xml file when I used the below URL http://domainname/shoponline/index.php/api/soap/?wsdl

I removed index.php but didn't get any result.

$proxy = new SoapClient('http://domain.com/magento/index.php/api/soap/?wsdl');

The above statement display the below error

Parsing WSDL: Couldn't find definitions in
like image 912
shylaja Avatar asked Jan 17 '26 09:01

shylaja


2 Answers

Looks like the WSDL XML file was not loaded at all. To debug, try to open this file in your browser. I guess it will not be loaded at all and you'll get an error (which will help you to find out what's wrong) or you will be asked to input username and password (basic HTTP auth). In the second case try change your URL from http://domain.com/magento/index.php/api/soap/?wsdl to http://user:[email protected]/magento/index.php/api/soap/?wsdl

like image 93
vsushkov Avatar answered Jan 19 '26 21:01

vsushkov


Make sure you disable developer mode and error reporting in index.php.

like image 45
Daniel van der Garde Avatar answered Jan 19 '26 22:01

Daniel van der Garde