使用Soap服务
wsdl 文件
仅为您请求的服务生成WSDL文件。这意味着,不同的客户可能使用不同的服务,因此使用不同的WSDLs。
Magento 2 Web API使用WSDL 1.2,符合WS-I 2.0基本概要。
每个Magento 2的服务接口,是服务合同的一部分,是一个服务的WSDL。
若要消耗多个服务,必须在WSDL endpoint URL中指定它们。
| 服务 | WSDL endpoint URL | 可用的服务 | 
|---|---|---|
| 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 | 
| 原始服务接口名称 | 服务名称 | 
|---|---|
| \Magento\Customer\Service\V1\CustomerInterface | customerV1 | 
| \Magento\Customer\Service\V1\CustomerAccountServiceInterface | customerCustomerAccountServiceV1 | 
| \Enterprise\Customer\Service\V3\Customer\AddressInterface | enterpriseCustomerAddressV3 | 
认证
更多信息, 查看OAuth-based 认证
下面的PHP脚本说明如何获取access token:
<?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, 'context' => $context]);
$soapResponse = $soapClient->testModule1AllSoapAndRestV1Item($serviceArgs); ?>
          相关话题
- OAuth-based 认证
 - 服务合约
 - SOAP 参考