Magento 2.1.18 is the final 2.1.x release. After June 2019, Magento 2.1.x will no longer receive security patches, quality fixes, or documentation updates.
To maintain your site's performance, security, and PCI compliance, upgrade to the latest version of Magento.

Use SOAP Services

WSDL File

A WSDL file is generated only for services that you request. This means that different clients may use different services and therefore use different WSDLs.

The Magento web API uses WSDL 1.2, which complies with WS-I 2.0 Basic Profile.

Each Magento service interface that is part of a service contract is represented as a separate service in the WSDL.

To consume several services, you must specify them in the WSDL endpoint URL.

Service WSDL endpoint URL Available services
customer http://magentohost/soap?wsdl&services=customerV1 \Magento\Customer\Service\V1\CustomerService
customer, catalogProduct http://magentohost/soap/custom_store?wsdl&services=customerCustomerAccountServiceV1,catalogProductV2 \Magento\Customer\Service\V1\CustomerAccountServiceInterface, \Magento\Catalog\Service\V2\ProductInterface

The WSDL URL follows the following pattern:

http://<magento.host>/soap/<optional_store_code>?wsdl&services=<service_name_1>,<service_name_2>

You must specify each service version in the endpoint URL.

This way, you can have a strict contract between your application and the service provider.

Service class-to-service name conversion rules

Service names use the following conventions:

  • CamelCase is used for service naming.
  • The string Service is omitted.
  • The Magento prefix is omitted.
  • The Interface suffix is omitted.
  • If the service name is the same as the module name, the module name is omitted. For example, if there is a customer service interface in the customer module, the word customer will be used in the service name only once.
Original Service Interface Name Service Name
\Magento\Customer\Service\V1\CustomerInterface customerV1
\Magento\Customer\Service\V1\CustomerAccountServiceInterface customerCustomerAccountServiceV1
\Enterprise\Customer\Service\V3\Customer\AddressInterface enterpriseCustomerAddressV3

Authentication

Protected SOAP resources can be accessed using bearer tokens (OAuth access tokens) over HTTP. Access tokens are strings representing an access authorization issued to the client. For more information, see OAuth-based authentication

The following PHP script illustrates how to get an access token:

1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
$opts = array(
            'http'=>array(
                'header' => 'Authorization: Bearer 36849300bca4fbff758d93a3379f1b8e'
            )
        );
$wsdlUrl = 'http://magento.ll/soap/default?wsdl=1&services=testModule1AllSoapAndRestV1';
$serviceArgs = array("id"=>1);

$context = stream_context_create($opts);
$soapClient = new SoapClient($wsdlUrl, ['version' => SOAP_1_2, 'stream_context' => $context]);

$soapResponse = $soapClient->testModule1AllSoapAndRestV1Item($serviceArgs); ?>
Updated