Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Soap Class Reference
Inheritance diagram for Soap:
FrontControllerInterface

Public Member Functions

 __construct (Request $request, \Magento\Framework\Webapi\Response $response, \Magento\Webapi\Model\Soap\Wsdl\Generator $wsdlGenerator, \Magento\Webapi\Model\Soap\Server $soapServer, ErrorProcessor $errorProcessor, \Magento\Framework\App\State $appState, \Magento\Framework\Locale\ResolverInterface $localeResolver, PathProcessor $pathProcessor, \Magento\Framework\Webapi\Rest\Response\RendererFactory $rendererFactory, \Magento\Framework\App\AreaList $areaList)
 
 dispatch (\Magento\Framework\App\RequestInterface $request)
 
- Public Member Functions inherited from FrontControllerInterface
 dispatch (RequestInterface $request)
 

Data Fields

const CONTENT_TYPE_SOAP_CALL = 'application/soap+xml'
 
const CONTENT_TYPE_WSDL_REQUEST = 'text/xml'
 

Protected Member Functions

 _isWsdlRequest ()
 
 _isWsdlListRequest ()
 
 _prepareErrorResponse ($exception)
 
 _setResponseContentType ($contentType='text/xml')
 
 _setResponseBody ($responseBody)
 
 validateWsdlRequest ()
 

Protected Attributes

 $_soapServer
 
 $_wsdlGenerator
 
 $_request
 
 $_response
 
 $_errorProcessor
 
 $_appState
 
 $_localeResolver
 
 $_pathProcessor
 
 $areaList
 
 $rendererFactory
 

Detailed Description

SOAP Web API entry point.

@SuppressWarnings(PHPMD.CouplingBetweenObjects)

Definition at line 20 of file Soap.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Request  $request,
\Magento\Framework\Webapi\Response  $response,
\Magento\Webapi\Model\Soap\Wsdl\Generator  $wsdlGenerator,
\Magento\Webapi\Model\Soap\Server  $soapServer,
ErrorProcessor  $errorProcessor,
\Magento\Framework\App\State  $appState,
\Magento\Framework\Locale\ResolverInterface  $localeResolver,
PathProcessor  $pathProcessor,
\Magento\Framework\Webapi\Rest\Response\RendererFactory  $rendererFactory,
\Magento\Framework\App\AreaList  $areaList 
)
Parameters
Request$request
Response$response
\Magento\Webapi\Model\Soap\Wsdl\Generator$wsdlGenerator
\Magento\Webapi\Model\Soap\Server$soapServer
ErrorProcessor$errorProcessor
\Magento\Framework\App\State$appState
\Magento\Framework\Locale\ResolverInterface$localeResolver
PathProcessor$pathProcessor
\Magento\Framework\Webapi\Rest\Response\RendererFactory$rendererFactory
\Magento\Framework\App\AreaList$areaList@SuppressWarnings(PHPMD.ExcessiveParameterList)

Definition at line 92 of file Soap.php.

103  {
104  $this->_request = $request;
105  $this->_response = $response;
106  $this->_wsdlGenerator = $wsdlGenerator;
107  $this->_soapServer = $soapServer;
108  $this->_errorProcessor = $errorProcessor;
109  $this->_appState = $appState;
110  $this->_localeResolver = $localeResolver;
111  $this->_pathProcessor = $pathProcessor;
112  $this->areaList = $areaList;
113  $this->rendererFactory = $rendererFactory;
114  }
$response
Definition: 404.php:11

Member Function Documentation

◆ _isWsdlListRequest()

_isWsdlListRequest ( )
protected

Check if current request is WSDL request. SOAP operation execution request is another type of requests.

Returns
bool

Definition at line 171 of file Soap.php.

172  {
173  return $this->_request->getParam(\Magento\Webapi\Model\Soap\Server::REQUEST_PARAM_LIST_WSDL) !== null;
174  }

◆ _isWsdlRequest()

_isWsdlRequest ( )
protected

Check if current request is WSDL request. SOAP operation execution request is another type of requests.

Returns
bool

Definition at line 161 of file Soap.php.

162  {
163  return $this->_request->getParam(\Magento\Webapi\Model\Soap\Server::REQUEST_PARAM_WSDL) !== null;
164  }

◆ _prepareErrorResponse()

_prepareErrorResponse (   $exception)
protected

Set body and status code to response using information extracted from provided exception.

Parameters
\Exception$exception
Returns
void

Definition at line 182 of file Soap.php.

183  {
184  $maskedException = $this->_errorProcessor->maskException($exception);
185  if ($this->_isWsdlRequest()) {
186  $httpCode = $maskedException->getHttpCode();
187  $contentType = self::CONTENT_TYPE_WSDL_REQUEST;
188  } else {
189  $httpCode = Response::HTTP_OK;
190  $contentType = self::CONTENT_TYPE_SOAP_CALL;
191  }
192  $this->_setResponseContentType($contentType);
193  $this->_response->setHttpResponseCode($httpCode);
194  $soapFault = new \Magento\Webapi\Model\Soap\Fault(
195  $this->_request,
196  $this->_soapServer,
197  $maskedException,
198  $this->_localeResolver,
199  $this->_appState
200  );
201  $this->_setResponseBody($soapFault->toXml());
202  }
_setResponseContentType($contentType='text/xml')
Definition: Soap.php:210
_setResponseBody($responseBody)
Definition: Soap.php:225

◆ _setResponseBody()

_setResponseBody (   $responseBody)
protected

Replace WSDL xml encoding from config, if present, else default to UTF-8 and set it to the response object.

Parameters
string$responseBody
Returns
$this

Definition at line 225 of file Soap.php.

226  {
227  $this->_response->setBody(
228  preg_replace(
229  '/<\?xml version="([^\"]+)"([^>]+)>/i',
230  '<?xml version="$1" encoding="' . $this->_soapServer->getApiCharset() . '"?>',
231  $responseBody
232  )
233  );
234  return $this;
235  }

◆ _setResponseContentType()

_setResponseContentType (   $contentType = 'text/xml')
protected

Set content type to response object.

Parameters
string$contentType
Returns
$this

Definition at line 210 of file Soap.php.

211  {
212  $this->_response->clearHeaders()->setHeader(
213  'Content-Type',
214  "{$contentType}; charset={$this->_soapServer->getApiCharset()}"
215  );
216  return $this;
217  }

◆ dispatch()

dispatch ( \Magento\Framework\App\RequestInterface  $request)

Dispatch SOAP request.

Parameters
\Magento\Framework\App\RequestInterface$request
Returns
\Magento\Framework\App\ResponseInterface

Definition at line 122 of file Soap.php.

123  {
124  $path = $this->_pathProcessor->process($request->getPathInfo());
125  $this->_request->setPathInfo($path);
126  $this->areaList->getArea($this->_appState->getAreaCode())->load(\Magento\Framework\App\Area::PART_TRANSLATE);
127  try {
128  if ($this->_isWsdlRequest()) {
129  $this->validateWsdlRequest();
130  $responseBody = $this->_wsdlGenerator->generate(
131  $this->_request->getRequestedServices(),
132  $this->_request->getScheme(),
133  $this->_request->getHttpHost(),
134  $this->_soapServer->generateUri()
135  );
136  $this->_setResponseContentType(self::CONTENT_TYPE_WSDL_REQUEST);
137  $this->_setResponseBody($responseBody);
138  } elseif ($this->_isWsdlListRequest()) {
139  $servicesList = [];
140  foreach ($this->_wsdlGenerator->getListOfServices() as $serviceName) {
141  $servicesList[$serviceName]['wsdl_endpoint'] = $this->_soapServer->getEndpointUri()
142  . '?' . \Magento\Webapi\Model\Soap\Server::REQUEST_PARAM_WSDL . '&services=' . $serviceName;
143  }
144  $renderer = $this->rendererFactory->get();
145  $this->_setResponseContentType($renderer->getMimeType());
146  $this->_setResponseBody($renderer->render($servicesList));
147  } else {
148  $this->_soapServer->handle();
149  }
150  } catch (\Exception $e) {
151  $this->_prepareErrorResponse($e);
152  }
153  return $this->_response;
154  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
_setResponseContentType($contentType='text/xml')
Definition: Soap.php:210
_setResponseBody($responseBody)
Definition: Soap.php:225
_prepareErrorResponse($exception)
Definition: Soap.php:182

◆ validateWsdlRequest()

validateWsdlRequest ( )
protected

Validate wsdl request

Returns
void
Exceptions

Definition at line 243 of file Soap.php.

244  {
246  $servicesParam = Request::REQUEST_PARAM_SERVICES;
247  $requestParams = array_keys($this->_request->getParams());
248  $allowedParams = [$wsdlParam, $servicesParam];
249  $notAllowedParameters = array_diff($requestParams, $allowedParams);
250  if (count($notAllowedParameters)) {
251  $notAllowed = implode(', ', $notAllowedParameters);
252  $message = __(
253  'Not allowed parameters: %1. Please use only %2 and %3.',
254  $notAllowed,
255  $wsdlParam,
256  $servicesParam
257  );
258  throw new \Magento\Framework\Webapi\Exception($message);
259  }
260  }
__()
Definition: __.php:13
$message

Field Documentation

◆ $_appState

$_appState
protected

Definition at line 57 of file Soap.php.

◆ $_errorProcessor

$_errorProcessor
protected

Definition at line 52 of file Soap.php.

◆ $_localeResolver

$_localeResolver
protected

Definition at line 62 of file Soap.php.

◆ $_pathProcessor

$_pathProcessor
protected

Definition at line 67 of file Soap.php.

◆ $_request

$_request
protected

Definition at line 42 of file Soap.php.

◆ $_response

$_response
protected

Definition at line 47 of file Soap.php.

◆ $_soapServer

$_soapServer
protected

#- #-

Definition at line 32 of file Soap.php.

◆ $_wsdlGenerator

$_wsdlGenerator
protected

Definition at line 37 of file Soap.php.

◆ $areaList

$areaList
protected

Definition at line 72 of file Soap.php.

◆ $rendererFactory

$rendererFactory
protected

Definition at line 77 of file Soap.php.

◆ CONTENT_TYPE_SOAP_CALL

const CONTENT_TYPE_SOAP_CALL = 'application/soap+xml'

#+ Content types used for responses processed by SOAP web API.

Definition at line 25 of file Soap.php.

◆ CONTENT_TYPE_WSDL_REQUEST

const CONTENT_TYPE_WSDL_REQUEST = 'text/xml'

Definition at line 27 of file Soap.php.


The documentation for this class was generated from the following file: