Implementing Magento 2 SOAP API

Today we will introduce you how to install SOAP API for Magento 2. Before using Magento 2 SOAP API, you should use SoapUI to test SOAP calls then starting implementing SOAP API.

You will start with WSDL file which is a XML Document with all available calls you can use to get data from the store. You can find SOAP V2 WSDL with the URL http://www.domain.com/index.php/api/v2_soap?wsdl=1

Replace www.domain.com with your domain

Then you will see a long xml file in browser like:

Magento2-SOAP-API-xmlIt is quite difficult when working with this WSDL file, so you need a tool to help. A recommended one is SoapUI which help speed up your development. This tool is written in Java so it can run on Linux, Windows and Mac OSX.

Step 1: Download SoapUI and install

Step 2: Login SoapUI

  • Open login Request 1, then you will see a window opened with soap xml code but you just need to care about 2 tags username and apiKey .
  • At the beginning of 2 tags are “?” so you need to change to avoid getting “Access denied” error when logging in SoapUI

Step 3: Define SOAP API users

  • Go to System> Web Services >SOAP/XML-RPC Users then you will see a list of all configured users for your API
  • Go to System> Web Services> SOAP/XML-RPC Roles to define roles for users
  • Create admin roles by selecting All in Role Resources tab
  • Create users
  • Set created admin role in User Role tab

Now you can fill all tags in your SoapUI Request window then run this request.

After that, you need come back a long number of digits and characters, copy your session id and store it.

We’ve introduced you the way to use SoapUI with SOAP API like login to get session id and creating a new API user role for Magento 2 backend. Hope you guys can understand and perform them.