Magento SOAP Access denied

2.7k views Asked by At

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?

3

There are 3 answers

0
NHK On BEST ANSWER

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

0
Jeffrey A. Gochin On

This sounds like an issue with CORS. (Cross Origin Resource Scripting) Consider Googling CORS and your particular development stack.

0
darleys On

The solution is to
1. create a new SOAP/XML-RPX Roles, say "Test"
2. in Role Resources just select "All" for Resource Access (just for testing)
3. Edit the user and assign the Role to "Test"