Skip to content

Commit deca2fe

Browse files
committed
updated implement doc
1 parent 6d9e75b commit deca2fe

7 files changed

+87
-0
lines changed

IMPLEMENT.md

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Implementing SOAP & REST API in Magento 2
2+
3+
*Unlock numerous possibilities with integrations for your eCommerce store with Magento integration. Let’s get started*
4+
5+
Magento web API framework is used to communicate third party services with the Magento System. In Magento 2, the web API allows exposure of the module API (service contact) through the WEB API. It extends the functionality from Magento 1 API.
6+
7+
Each repository and API are available through web API. It follows strict definition for all the classes, parameters and return values.
8+
9+
We have to declare a URL in webapi.xml and need to specify the required interfaces (available services) and methods for the APIs.
10+
11+
## Implementing SOAP & REST API in Magento 2
12+
13+
We have two types of protocols to make a repository available through web API
14+
15+
- [SOAP API](http://devdocs.magento.com/guides/v2.0/soap/bk-soap.html) (Simple Object Access Protocol)
16+
- [REST API](http://devdocs.magento.com/guides/v2.0/rest/rest_endpoints.html) (Representational State Transfer)
17+
18+
It is easier to implement REST API because it is less strict than SOAP API. The implementation is taken from the di.xml file, which calls the method.
19+
20+
The diagram below shows the process in detail.
21+
22+
![Magento 2 REST API Diagram](./assets/magento2_api.png)
23+
24+
## Example webapi.xml
25+
26+
![Example webapi](./assets/example1.jpg)
27+
28+
*Router* contains the URL and a method (GET, POST, and DELETE).
29+
30+
*Service* defines the interface class and the method for handling.
31+
32+
*Resources* defines the list of users (ACL Resource) for accessing the web API.
33+
34+
Three types of resources are available in Magento 2 for the web API
35+
36+
1. *Self* – available for customer data
37+
2. *Anonymous* – available for all
38+
3. *Magento ACL* – Admin user (this requires permissions)
39+
40+
## Web API Authentication
41+
42+
There are three types of Authentication
43+
44+
1. OAuth
45+
2. Token Based
46+
3. Session Based
47+
48+
For Token based authentication, we need to create an Admin user with specific permission.
49+
50+
## Integration of Web API
51+
52+
To create an integration, click System > Integration > Add New Integration. Be sure to restrict the resources that the integration can access.
53+
54+
Below are the screen shots of the procedure for new Integration and Activation.
55+
56+
![New Integration](./assets/new-integration.jpg)
57+
58+
![Integrations](./assets/integrations.jpg)
59+
60+
![Integration Token](./assets/integration-token.jpg)
61+
62+
## SOAP WSDL URL
63+
64+
WSDL is generated automatically for both system and custom services.
65+
66+
### WSDL Structure
67+
68+
``http://You Magento Host / soap?wsdl&services= [Defined List of services]``
69+
70+
Example:
71+
72+
![Example WSDL](./assets/example2.jpg)
73+
74+
## REST Authentication
75+
76+
### This supports token based authentication.
77+
URL for accessing through REST
78+
79+
``http://{Your Magento Repo}/rest/V1/ConsumerRepo?{Arguments}``
80+
81+
### Example:
82+
83+
``curl -X GET "http://127.0.0.1/m2/rest/V1/ConsumerRepo" –H "Authentication : Bearer_Token-"``
84+
85+
One of the many goals of Magento 2 is to improve on the web APIs. For more information on Magento 2 web API , please go through the documentation below
86+
87+
http://devdocs.magento.com/guides/v2.0/get-started/bk-get-started-api.html

assets/example1.jpg

22.9 KB
Loading

assets/example2.jpg

31.2 KB
Loading

assets/integration-token.jpg

18.5 KB
Loading

assets/integrations.jpg

16.6 KB
Loading

assets/magento2_api.png

12.6 KB
Loading

assets/new-integration.jpg

13.6 KB
Loading

0 commit comments

Comments
 (0)