/** * {@inheritdoc} */ public function call($serviceInfo, $arguments = [], $storeCode = null, $integration = null) { $soapOperation = $this->_getSoapOperation($serviceInfo); $arguments = $this->_converter->convertKeysToCamelCase($arguments); $soapResponse = $this->_getSoapClient($serviceInfo, $storeCode)->{$soapOperation}($arguments); //Convert to snake case for tests to use same assertion data for both SOAP and REST tests $result = is_array($soapResponse) || is_object($soapResponse) ? $this->toSnakeCase($this->_converter->convertStdObjectToArray($soapResponse, true)) : $soapResponse; /** Remove result wrappers */ $result = isset($result[SoapHandler::RESULT_NODE_NAME]) ? $result[SoapHandler::RESULT_NODE_NAME] : $result; return $result; }
/** * Convert service response into format acceptable by SoapServer. * * @param object|array|string|int|float|null $data * @param string $serviceClassName * @param string $serviceMethodName * @return array * @throws \InvalidArgumentException */ protected function _prepareResponseData($data, $serviceClassName, $serviceMethodName) { /** @var string $dataType */ $dataType = $this->methodsMapProcessor->getMethodReturnType($serviceClassName, $serviceMethodName); $result = null; if (is_object($data)) { $result = $this->_dataObjectConverter->convertKeysToCamelCase($this->_dataObjectProcessor->buildOutputDataArray($data, $dataType)); } elseif (is_array($data)) { $dataType = substr($dataType, 0, -2); foreach ($data as $key => $value) { if ($value instanceof ExtensibleDataInterface || $value instanceof MetadataObjectInterface) { $result[] = $this->_dataObjectConverter->convertKeysToCamelCase($this->_dataObjectProcessor->buildOutputDataArray($value, $dataType)); } else { $result[$key] = $value; } } } elseif (is_scalar($data) || $data === null) { $result = $data; } else { throw new \InvalidArgumentException("Service returned result in invalid format."); } return [self::RESULT_NODE_NAME => $result]; }