Search code examples
phpsoapmagento-1.9access-denied

Magento SOAP Access denied


When I tried to call my local Magento 1.9 using webservice using the following code, it seems that it is giving me access denied error.

I had no problem using SOAPUI (or other soap client) to call the same address.

PHP code

<?php
$client = new SoapClient('http://localhost/magento/index.php/api/soap/?wsdl', array('trace' => 1));

$session = $client->login('apiuser', 'apikey');

echo "REQUEST:\n" . $client->__getLastRequest() . "\n";
echo "Response:\n" . $client->__getLastResponse() . "\n";
?>

Respond:

$ php -f catalog_product_list.php
PHP Fatal error:  Uncaught SoapFault exception: [2] Access denied. in /catalog_product_list.php:5
Stack trace:
#0 /catalog_product_list.php(5): SoapClient->__call('login', Array)
#1 /catalog_product_list.php(5): SoapClient->login('apiuser', 'apikey')
#2 {main}
  thrown in /catalog_product_list.php on line 4

I had used the same code to call a remote copy and it is ok. What can be the problem?


Solution

  • previous i was using this address. either php or soapui works.

    http://localhost/magento/index.php/api/?wsdl

    now i am using this address in both my soapui and php. both are working now. http://localhost/magento/index.php/api/soap/?wsdl