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:
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 2
API format in Magento 2:
http://magento2.url/soap?wsdl_list=1
Create User and Role to use API
Create Role
- In your Magento backend, go to System > Web Services > SOAP/XML-RPC – Roles.
- Click Add New Role.
- Under Role Info, enter a name for this role. You may need to enter current admin password to continue.
- Under Role Resources, choose which resources this role can access to.
Create User
- In your Magento backend, go to System > Web Services > SOAP/XML-RPC – Users.
- Click Add New User.
- Under User Info, enter the necessary information.
- 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);
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
An Error occurred while handling another error:
exception ‘ReflectionException’ with message ‘Method SoapClient::login() does not exist’ in
Hello Dom thanks for informative article. Just a problem like you print_r and debug the object. How can i see raw xml on browser from this script? please guide me
As a vital component of the kyrgyz national university network, Osh University is a trusted choice for higher education, providing students with a supportive environment and a rich academic experience.
Shalamar Hospital is your premier choice for urological care, boasting the best urologist in Pakistan . Trust us for expert treatments and exceptional patient care.
Elevate your fashion game with Jewel Galore’s bridal jewellery set. These unique pieces add a touch of luxury and individuality to your look, making a bold statement.