Magento Tutorials

Understanding Magento SOAP API

What is SOAP API?

SOAP (Simple Object Access Protocol) is a protocol for transmitting structured information in computer networks. It uses XML for its message format, which allows computers running on different platforms (Windows and Linux, e.g.) to communicate to each other, as long as those computers support web service protocol (HTTP for example).

Magento SOAP API

Magento 1 and Magento 2 are both SOAP-included.

Magento 1

API format in Magento 1:

http://magento.url/api/soap/?wsdl

XML result:

magento 1 api

From Magento version 1.3, SOAP API is updated into version 2 to better support Java and .NET. Hence, URL format is changed into:

http://magento.url/api/v2_soap?wsdl=1
magento 1.3 api

Magento 2

API format in Magento 2:

http://magento2.url/soap?wsdl_list=1
magento 2 api

Create User and Role to use API

Create Role

  1. In your Magento backend, go to System > Web Services > SOAP/XML-RPC – Roles.
  2. Click Add New Role.
  3. Under Role Info, enter a name for this role. You may need to enter current admin password to continue.
  4. Under Role Resources, choose which resources this role can access to.

Create User

  1. In your Magento backend, go to System > Web Services > SOAP/XML-RPC – Users.
  2. Click Add New User.
  3. Under User Info, enter the necessary information.
  4. Under User Role, select a role for this user.

Example: Using SOAP API in PHP to get category tree

SOAP v1:

$client = new SoapClient('http://localhost.com/magento19/api/soap/?wsdl');
$session = $client->login('apiUser', 'apiKey');
$result = $client->call($session, 'catalog_category.info', '5');
var_dump($result);

SOAP v2:

$proxy = new SoapClient('http://localhost.com/magento19/api/v2_soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey'); // TODO : change login and pwd if necessary
$result = $proxy->catalogCategoryInfo($sessionId, '5');
var_dump($result);
soap v2 api

You can refer to APIs in this Magento document:  http://devdocs.magento.com/guides/m1x/api/soap-api-index.html


Read more:
How to Use AJAX Requests in Magento
Magento API for Android