How to Import Data via SOAP API into Magento 2

Magento 2 SOAP API Data Import

Below, we shed light on how to enable Magento 2 SOAP API import. Unfortunately, this functionality is not possible by default, but you can add the missing feature to your e-commerce store with the help of a third-party extension. The following article sheds light on SOAP, compares it with REST, and offers a reliable tool for enabling the corresponding functionality for Magento 2. You can leverage the Magento 2 SOAP API import and export processes with the Improved Import & Export Magento 2 module

The following article sheds light on how to import data into Magento 2 via SOAP API with the help of our extension. We discuss how to enable the Magento 2 SOAP API import and what extra benefits you can get. If you are not familiar with what SOAP API is, we’ve also prepared a chapter that describes this standard. Besides, there is an FAQ section that provides answers to frequently asked questions about SOAP and Magento 2 import/export processes.

Please Note: Connection to complex 3rd-party API may require custom development on top of our Improved Import & Export. Our solution is 100% open source, so we would be happy to advise how to add the necessary functionality. We can also provide you with a quote for any integration – contact us.

Why SOAP?

SOAP provides web apps with the ability to communicate over the Internet over HTTP, which is supported by all Internet browsers and servers. Applications can run on different operating systems, with different technologies and programming languages.

Magento 2 SOAP API Import

SOAP stands for Simple Object Access Protocol. Being an XML-based messaging protocol for exchanging structured information, it is characterized by extensibility, neutrality, and independence. It relies on such application layer protocols as HTTP and SMTP for message negotiation and transmission but at the same time is not tied to any particular transport protocols, operating systems, or programming languages.  

Thus, SOAP is an essential building block for developing distributed apps that exploit functionality published as services over the internet. And, as you might have already guessed, it introduces extended capabilities when it comes to data transfers between Magento 2 and external systems. The only requirement is the necessity to formulate and understand SOAP messages.

You can quickly achieve this goal with the help of the Improved Import & Export Magento 2 extension. The module makes your e-commerce store suitable for data transfers on the basis of SOAP APIs. Since the format is extremely flexible, it means that you can effortlessly connect Magento 2 to any external systems that also support this messaging protocol. In combination with Improved Import features, you get the following benefits of the Magento 2 SOAP API import:

  • Flexible data transfers from any external systems to Magento 2;
  • Fully automated schedules of updates;
  • No need to rely on data transfers;
  • Advanced mapping functionality.

Below, we shed light on these and other features of the Magento 2 SOAP API connector provided with the Improved Import & export extension.

Magento 2 SOAP API Connector

To make Magento 2 SOAP API import more user-friendly, the connector introduces two essential features: schedules and mapping. Both are designed to synchronize your e-commerce store with external systems and make data exchange fully automated.

Magento 2 SOAP API Import Schedules

The Improved Import & Export extension supports cron allowing you to create any custom schedule of updates. You only need to learn the default cron syntax if you didn’t do that before. The module lets you create any custom interval to start Magento 2 SOAP API import when necessary in a fully automated manner. At the same time, you can launch every update asynchronously in a manual mode.

Alternatively, the extension provides the ability to select one of the predefined intervals is you don’t want to deal with the cron syntax. Note that manual updates are also possible in this case. And you can always create import profiles designed for a manual run only. The following gif image illustrates the corresponding functionality of the Magento 2 SOAP API connector:

Magento 2 SOAP API Import Mapping

Another vital improvement introduced with the Improved Import & Export Magento 2 extension is its mapping interface. It’s not a secret that you cannot transfer data from one system to another without modifying it. The problem is caused by different attribute standards used by external platforms. It is even impossible to move information from Magento 1.x to 2.x without editing. Luckily, the Magento 2 SOAP API connector provides a user-friendly way to make any external output suitable for the default requirements of your e-commerce store.

The Improved Import & Export module offers an intuitive interface where you can map external attributes to local Magento 2 ones. The process is as simple as shown below:

Attribute mapping

Mapping Presets

But you can simplify the procedure above with the help of mapping presets. The Improved Import & Export Magento 2 extension offers an opportunity to use the predefined mapping scheme instead of creating it. Thus, attribute matching is simplified to a few clicks like shown below:

Unfortunately, we cannot provide mapping presets that cover all integrations. Therefore, contact our support regarding mapping schemes for your particular business case.

Get Improved Import & Export Magento 2 Extension

Other Features

Since we are talking about the features of the Improved Import & Export extension, we’d like to draw your attention to some more useful characteristics of our module that are not used in the Magento 2 SOAP API connector but can be suitable for your business needs.

Multiple File Formats

The Improved Import & Export Magento 2 extension works with numerous file formats. In addition to default CSV, it also works with XML, which is widely used by many external systems. To make connectivity opportunities even more flexible and powerful, we’ve also added JSON support. Besides, the module uses XLS and XLSX for various internal purposes. As for CSV, XML, and JSON, you can effortlessly import/export data in these formats.

Multiple File Sources

When it comes to data file transfers, we should also draw your attention to file sources. The Improved Import & Export Magento 2 extension offers three different options:

  • FTP/SFTP. You can use a local or remote server as a file source;
  • Dropbox. The cloud storage can be utilized for the same purposes;
  • URP. Data file import is possible via a direct URL.

Note that in the case of import processes, the extension unzips/untars all compressed data automatically.

Alternative Ways of Import/Export

In addition to file transfers, the Improved Import & Export Magento 2 extension supports two more ways of file transfers: Google Sheets Data Import and REST API Synchronization. Follow the corresponding links to find out more about each process. As for the additional features of the module, you can discover them in the following video:

SOAP API Characteristics

Now, when you know critical aspects of the Magento 2 SOAP API import and are familiar with the features of the connector, let’s focus on several essential SOAP API characteristics.

SOAP Protocol Parts

SOAP provides the Messaging Protocol layer of a web services protocol stack. An XML-based protocol consists of three parts:

  • Envelope;
  • Encoding Rules;
  • Representing Convention.

The envelope part defines the structure of a message and the way to process it. Next, the set of encoding rules express instances of application-defined data types. The convention part is used for representing procedure calls and responses.

SOAP Major Characteristics

Specialists highlight three significant characteristics of SOAP. First of all, it is extensibility: the standard is extremely flexible and can be used for satisfying even the most complicated business cases. Next, it is neutrality: as mentioned above, SOAP can operate over any protocol. The third key feature of SOAP is independence: you can fully leverage the standard for any programming model.

Let’s explore a situation for a better understanding of what SOAP can do:

  • Imagine, there is an application that sends a SOAP request to a server with enabled web services.
  • The request includes the parameters for a search.
  • The server returns a SOAP response with the required data in the form of an XML-formatted document.
  • The requesting application can integrate the returned data directly.

That is a general model for all requests. We describe the process in more details in the corresponding section below.

SOAP Specification Layers

It is also necessary to mention that the SOAP architecture consists of several layers of specifications. Each layer is utilized for a specific purpose.

  • First of all, there is a specification for a message format.
  • Next, SOAP includes a layer for Message Exchange Patterns.
  • Underlying transport protocol bindings and message processing models are also linked to corresponding layers.
  • And there is a protocol extensibility layer.

Now, let’s explore a more complex example to get a better degree of what SOAP is.

SOAP Building Blocks

Being an ordinary XML document, a SOAP message contains the following elements:

  • Envelope. This element identifies the XML document as a SOAP message.
  • Header. The role of this element is to contain header information.
  • Body. This one is developed to contain call and response information.
  • Fault. Errors and status information are gathered here.

SOAP Syntax Rules

Below, you can see what a SOAP message must and must not do. It must

  • be encoded using XML;
  • use the SOAP Envelope namespace;
  • use the SOAP Encoding namespace.

At the same time, a SOAP message must not

  • contain a DTD reference;
  • include XML Processing Instructions.

SOAP Skeleton Message

Below, you can see a skeleton SOAP message example:

SOAP API Example

Basic Concept

Let’s assume that there is a straightforward corporate database that holds a table specifying such parameters as

  • Employee reference number;
  • Name;
  • Telephone number.

Now, you need to provide other company systems with this data. Your new service should return a name and a telephone number for a given employee reference number. A two element array of strings is returned to an integer. A Java-style prototype for the similar service looks as follows:

What is the SOAP developer’s approach to such a problem, you will ask? It may be narrowed down to the encapsulation of the database request logic for the service in a method. Next, it sets up a process that listens for requests (in SOAP format with the service name and any required parameters) to the service. As you already know, the transport layer might be HTTP, SMTP, or anything else.

Now, we should focus on the listener process. To make the system more developer-friendly, specialists recommend writing it in the same language as the service method. The process itself serves several purposes. It decodes the incoming SOAP request and then transforms it into an invocation of the method. Now, it is time to take the result of the method call and encode it into a SOAP message (which is also our response). Finally, the response can be sent back to the requester. The following image illustrates the concept behind the arrangement:

Magento 2 SOAP API Data Import

More Specific Example

The same arrangement can be implemented within many different architectures. Let’s take a look at a more specific example with the following characteristics:

  • The Oracle database;
  • The service method in Java;
  • Database connections via JDBC Oracle implementation;
  • The listener process is a Java Servlet within the Tomcat Servlet Engine.
  • The servlet
    • has access to some Java classes capable of decoding and encoding SOAP messages
    • is listening for those messages as an HTTP POST.
  • The transport is HTTP over TCP/IP.
  • The client is an Excel spreadsheet with a VB Macro to utilize the Microsoft SOAP Toolkit for encoding a SOAP request and decoding the response received.

By adding all these conditions, we make the aforementioned scheme much more complicated. Just take a look at the current illustration of the specific implementation:

Magento 2 SOAP API Data Import

If you are an e-commerce merchant, it should look like a mess. Luckily, there is the Improved Import & Export Extension that implements all the necessary mechanisms to establish the direct connection between your website and the external system. You only need to install the module and specify several parameters required by the integration. The necessity to master all technical aspects of the Magento 2 SOAP import is eliminated.

SOAP API vs. REST API

Magento 2 SOAP API Data Import

Since we’ve already written about the Magento 2 REST API import, it is necessary to say a few words about the difference between both processes. First of all, you should understand that SOAP and REST can’t be compared directly. The first is a protocol while the second is an architectural style. But it doesn’t mean that we cannot find any differences.

SOAP and REST has a different degree of coupling between client and server implementations. If we are talking about a SOAP client, it works as a custom desktop application. The app in its turn is tightly coupled to the server with all the consequences. Due to an inflexible contract between the client and the server, the connection crashes if either side changes anything.

As for the REST client, it acts more like a browser. The generic client knows how to use a protocol and standardized methods so that an application has to fit inside that. By creating extra methods, you don’t violate the protocol standards. Instead, you leverage the standard methods of forming actions with them on your media type. As a result, REST helps to reduce coupling and leads to the situation when changes are dealt more gracefully.

Besides, a client enters a REST service with the zero knowledge of the API, except for the entry point and the media type. In the case of SOAP, the client needs to know everything it will be using. Otherwise, the interaction won’t begin.

Also, note that a REST client can be extended by code-on-demand. It must be supplied by the server itself. As an example, we can name the JavaScript code used to drive the interaction with another service on the client-side.

For further information, check the following links that describe various aspects of SOAP.

SOAP API Links

Conclusion

As you can see, SOAP is a quite complex topic that cannot be explored in a single article. But our purpose was to draw your attention to new opportunities instead of reinventing the wheel by combining the information from multiple sources in this blog post. You don’t need to learn the plethora of the information mentioned above to connect your Magento 2 website to an external system. Now, you only need to install the Improved Import & Export Magento 2 extension since it offers the Magento 2 SOAP API connector. Here are several reasons to do that:

  • No coding is required – we’ve already coded everything for you;
  • Data import can be fully automated since our plugin offers cron-based scheduling;
  • You can seamlessly import data from external systems which use different attribute standards with the advanced mapping interface of the module;
  • The connector helps to save time necessary for the implementation and maintenance of the data flow.

For any further information about the Improved Import & Export Magento 2 extension, follow this link:

Get Improved Import & Export Magento 2 Extension

Please Note: Connection to complex 3rd-party API may require custom development on top of our Improved Import & Export. Our solution is 100% open source, so we would be happy to advise how to add the necessary functionality. We can also provide you with a quote for any integration – contact us.

Magento 2 SOAP API Import & Export FAQ

How to import products to Magento 2 via SOAP API?

You can effortlessly transfer products to Magento 2 via SOAP API with the help of the Improved Import & Export extension. Create a new import job that will connect your e-commerce website to the destination that contains the data you want to transfer to your database. Next, provide the credentials for the point of data exchange, create a schedule of data transfers, and apply a mapping scheme to replace unsupported attributes with the ones used in Magento 2. All product types are supported, including gift cards!

How to export products to Magento 2 via SOAP API?

The Improved Import & Export plugin offers functionality similar to the one described above for export processes so that you can easily transfer products from Magento 2 to a remote destination via SOAP API. Along with the corresponding import job, it creates a bi-directional SOAP API connection between Magento 2 and an external system.

How to import categories to Magento 2 via SOAP API?

Transferring categories to Magento 2 via SOAP API is possible with the Improved Import & Export extension. Create a new import job that connects your e-commerce website to the destination that contains category data. Provide the credentials for the point of data exchange, create a schedule of data transfers, and apply a mapping scheme to replace unsupported category attributes with the ones used in Magento 2. Note that the Improved Import & Export supports all category data and lets you map external categories to the ones available in the existing category tree.

How to export categories to Magento 2 via SOAP API?

The Improved Import & Export extension offers functionality similar to the one described above for export processes so that you can easily transfer categories from Magento 2 to a remote destination via SOAP API. Along with the corresponding import job, it creates a bi-directional SOAP API connection between Magento 2 and an external system.

How to import orders to Magento 2 via SOAP API?

Moving orders to Magento 2 via SOAP API is another daily duty that the Improved Import & Export extension can cope with. It is only necessary to create a new import job that connects your e-commerce website to the destination that contains order data. Provide the credentials for the point of data exchange, create a schedule of data transfers, and apply a mapping scheme to replace unsupported order attributes with the ones used in Magento 2. Note that the Improved Import & Export imports all order data, including documents and tracking information.

How to export orders to Magento 2 via SOAP API?

The Improved Import & Export plugin offers functionality similar to the one described above for export processes so that you can easily transfer orders from Magento 2 to a remote destination via SOAP API. Along with the corresponding import job, it creates a bi-directional SOAP API connection between Magento 2 and an external system.

How to import customers to Magento 2 via SOAP API?

The Improved Import & Export extension lets you transfer customers to Magento 2 via SOAP API. Create a new import job that connects your e-commerce website to the destination that contains customer data. Provide the credentials for the point of data exchange, create a schedule of data transfers, and apply a mapping scheme to replace unsupported customer attributes with the ones used in Magento 2. Note that the plugin transfers customers with all the related information, including customer addresses, groups, billing/shipping details, etc.

How to export customers to Magento 2 via SOAP API?

The Improved Import & Export module offers functionality similar to the one described above for export processes so that you can easily transfer customers from Magento 2 to a remote destination via SOAP API. Along with the corresponding import job, it creates a bi-directional SOAP API connection between Magento 2 and an external system.

How to import B2B entities to Magento 2 via SOAP API?

The Improved Import & Export extension is not enough for transferring B2B entities between Magento 2 and external systems. However, you can use its B2B add-on for enabling the necessary functionality. The add-on lets you create a new import job that connects your e-commerce website to the destination with the B2B entities. You can import the following B2B entities: companies, requisitions lists, shared catalogs, quotes, and negotiation quotes.

How to export B2B entities to Magento 2 via SOAP API?

The Improved Import & Export extension along with its add-on offers functionality similar to the one described above for export processes so that you can easily transfer B2B entities from Magento 2 to a remote destination via SOAP API. Along with the corresponding import job, it creates a bi-directional SOAP API connection between Magento 2 and an external system.

How to automate SOAP API import and export processes in Magento 2?

The Improved Import & Export Magento 2 extension leverages cron to let you automate SOAP API import and export processes. Consequently, you can specify intervals to launch the corresponding data transfers automatically.

How to import data with unsupported attributes to Magento 2 via SOAP API?

The Improved Import & Export not only provides SOAP API import and export processes but also offers a robust mapping interface, where you can match unsupported attributes to ones used in Magento 2. As a result, the system replaces all the unsuitable data, enabling import from external systems with no additional data modifications.