Test client for SOAP API testing.
Definition at line 15 of file Soap.php.
◆ _getSoapClient()
_getSoapClient |
( |
|
$serviceInfo, |
|
|
|
$storeCode = null |
|
) |
| |
|
protected |
Get proper SOAP client instance that is initialized with WSDL corresponding to requested service interface.
- Parameters
-
string | $serviceInfo | PHP service interface name, should include version if present |
string | null | $storeCode | |
- Returns
- \Zend\Soap\Client
Check if there is SOAP client initialized with requested WSDL available
Definition at line 72 of file Soap.php.
79 if (!isset($this->_soapClients[$wsdlUrl])) {
80 $token = isset($serviceInfo[
'soap'][
'token']) ? $serviceInfo[
'soap'][
'token'] :
null;
83 return $this->_soapClients[$wsdlUrl];
instantiateSoapClient($wsdlUrl, $token=null)
_getSoapServiceVersion($serviceInfo)
_getSoapServiceName($serviceInfo)
generateWsdlUrl($services, $storeCode=null)
◆ _getSoapOperation()
_getSoapOperation |
( |
|
$serviceInfo | ) |
|
|
protected |
Retrieve SOAP operation name from available service info.
- Parameters
-
- Returns
- string
- Exceptions
-
Definition at line 148 of file Soap.php.
150 if (isset($serviceInfo[
'soap'][
'operation'])) {
151 $soapOperation = $serviceInfo[
'soap'][
'operation'];
152 }
elseif (isset($serviceInfo[
'serviceInterface']) && isset($serviceInfo[
'method'])) {
153 $soapOperation = $this->_soapConfig->getSoapOperation(
154 $serviceInfo[
'serviceInterface'],
155 $serviceInfo[
'method']
158 throw new \LogicException(
"SOAP operation cannot be identified.");
160 return $soapOperation;
elseif(isset( $params[ 'redirect_parent']))
◆ _getSoapServiceName()
_getSoapServiceName |
( |
|
$serviceInfo | ) |
|
|
protected |
Retrieve service name from available service info.
- Parameters
-
- Returns
- string
- Exceptions
-
Definition at line 206 of file Soap.php.
208 if (isset($serviceInfo[
'soap'][
'service'])) {
209 $serviceName = $serviceInfo[
'soap'][
'service'];
210 }
elseif (isset($serviceInfo[
'serviceInterface'])) {
211 $serviceName = $this->_soapConfig->getServiceName($serviceInfo[
'serviceInterface'],
false);
213 throw new \LogicException(
"Service name cannot be identified.");
elseif(isset( $params[ 'redirect_parent']))
◆ _getSoapServiceVersion()
_getSoapServiceVersion |
( |
|
$serviceInfo | ) |
|
|
protected |
Retrieve service version from available service info.
- Parameters
-
- Returns
- string
- Exceptions
-
Normalize version
Definition at line 170 of file Soap.php.
172 if (isset($serviceInfo[
'soap'][
'operation'])) {
178 }
elseif (isset($serviceInfo[
'serviceInterface'])) {
180 \
Magento\Webapi\Model\Config::SERVICE_CLASS_PATTERN,
181 $serviceInfo[
'serviceInterface'],
184 if (isset($matches[3])) {
192 throw new \LogicException(
"Service version cannot be identified.");
elseif(isset( $params[ 'redirect_parent']))
◆ call()
call |
( |
|
$serviceInfo, |
|
|
|
$arguments = [] , |
|
|
|
$storeCode = null , |
|
|
|
$integration = null |
|
) |
| |
{Perform call to the specified service method.
- Parameters
-
array | $serviceInfo |
array(
'rest' => array(
'resourcePath' => $resourcePath, // e.g. /products/:id
'httpMethod' => $httpMethod, // e.g. GET
'token' => '21hasbtlaqy8t3mj73kjh71cxxkqj4aq' // optional : for token based Authentication. Will
override default Oauth based authentication provided
by test framework
),
'soap' => array(
'service' => $soapService, // soap service name with Version suffix e.g.
catalogProductV1, customerV2
'operation' => $operation // soap operation name e.g. catalogProductCreate
'token' => '21hasbtlaqy8t3mj73kjh71cxxkqj4aq' // optional : for token based Authentication. Will
override default Oauth based authentication provided
by test framework
),
OR
'serviceInterface' => $phpServiceInterfaceName, // e.g. \Magento\Catalog\Api\ProductInterface
'method' => $serviceMethodName // e.g. create
'entityId' => $entityId // is used in REST route placeholder (if applicable)
);
|
array | $arguments | |
string | null | $storeCode | if store code not provided, default store code will be used |
\Magento\Integration\Model\Integration | null | $integration | |
- Returns
- array|string|int|float|bool
}
Remove result wrappers
Implements AdapterInterface.
Definition at line 51 of file Soap.php.
57 $result = (is_array($soapResponse) || is_object($soapResponse))
58 ? $this->
toSnakeCase($this->_converter->convertStdObjectToArray($soapResponse,
true))
_getSoapOperation($serviceInfo)
toSnakeCase(array $objectData)
_getSoapClient($serviceInfo, $storeCode=null)
◆ generateWsdlUrl()
generateWsdlUrl |
( |
|
$services, |
|
|
|
$storeCode = null |
|
) |
| |
Generate WSDL URL.
- Parameters
-
array | $services | e.g.
array(
'catalogProductV1',
'customerV2'
); |
string | null | $storeCode | |
- Returns
- string
Sort list of services to avoid having different WSDL URLs for the identical lists of services.
TESTS_BASE_URL is initialized in PHPUnit configuration
Definition at line 120 of file Soap.php.
127 ->get(\
Magento\Store\Model\StoreManagerInterface::class)
133 $wsdlUrl = rtrim(TESTS_BASE_URL,
'/') . self::WSDL_BASE_PATH .
'/' .
$storeCode .
'?wsdl=1&services=';
134 $wsdlResourceArray = [];
135 foreach ($services as $serviceName) {
136 $wsdlResourceArray[] = $serviceName;
138 return $wsdlUrl . implode(
",", $wsdlResourceArray);
static getObjectManager()
◆ instantiateSoapClient()
instantiateSoapClient |
( |
|
$wsdlUrl, |
|
|
|
$token = null |
|
) |
| |
Create SOAP client instance and initialize it with provided WSDL URL.
- Parameters
-
- Returns
- \Zend\Soap\Client
Definition at line 93 of file Soap.php.
95 $accessCredentials =
$token 97 : \Magento\TestFramework\Authentication\OauthHelper::getApiAccessCredentials()[
'key'];
98 $opts = [
'http' => [
'header' =>
"Authorization: Bearer " . $accessCredentials]];
99 $context = stream_context_create(
$opts);
100 $soapClient = new \Zend\Soap\Client($wsdlUrl);
101 $soapClient->setSoapVersion(SOAP_1_2);
102 $soapClient->setStreamContext($context);
103 if (TESTS_XDEBUG_ENABLED) {
104 $soapClient->setCookie(
'XDEBUG_SESSION', 1);
◆ toSnakeCase()
toSnakeCase |
( |
array |
$objectData | ) |
|
|
protected |
Recursively transform array keys from camelCase to snake_case.
Utility method for converting SOAP responses. Webapi framework's SOAP processing outputs snake case Data Object properties(ex. item_id) as camel case(itemId) to adhere to the WSDL. This method allows tests to use the same data for asserting both SOAP and REST responses.
- Parameters
-
array | $objectData | An array of data. |
- Returns
- array The array with all camelCase keys converted to snake_case.
Definition at line 228 of file Soap.php.
231 foreach ($objectData as $key =>
$value) {
232 $key = strtolower(preg_replace(
"/(?<=\\w)(?=[A-Z])/",
"_$1", $key));
toSnakeCase(array $objectData)
◆ $_converter
◆ $_soapClients
◆ $_soapConfig
◆ WSDL_BASE_PATH
const WSDL_BASE_PATH = '/soap' |
The documentation for this class was generated from the following file:
- vendor/magento/magento2-base/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/Webapi/Adapter/Soap.php