/** * Dispatch SOAP request. * * @param \Magento\Framework\App\RequestInterface $request * @return \Magento\Framework\App\ResponseInterface */ public function dispatch(\Magento\Framework\App\RequestInterface $request) { $path = $this->_pathProcessor->process($request->getPathInfo()); $this->_request->setPathInfo($path); $this->areaList->getArea($this->_appState->getAreaCode())->load(\Magento\Framework\App\Area::PART_TRANSLATE); try { if ($this->_isWsdlRequest()) { $this->validateWsdlRequest(); $responseBody = $this->_wsdlGenerator->generate($this->_request->getRequestedServices(), $this->_request->getScheme(), $this->_request->getHttpHost(), $this->_soapServer->generateUri()); $this->_setResponseContentType(self::CONTENT_TYPE_WSDL_REQUEST); $this->_setResponseBody($responseBody); } else { if ($this->_isWsdlListRequest()) { $servicesList = []; foreach (array_keys($this->_wsdlGenerator->getListOfServices()) as $serviceName) { $servicesList[$serviceName]['wsdl_endpoint'] = $this->_soapServer->getEndpointUri() . '?' . \Magento\Webapi\Model\Soap\Server::REQUEST_PARAM_WSDL . '&services=' . $serviceName; } $renderer = $this->rendererFactory->get(); $this->_setResponseContentType($renderer->getMimeType()); $this->_setResponseBody($renderer->render($servicesList)); } else { $this->_soapServer->handle(); } } } catch (\Exception $e) { $this->_prepareErrorResponse($e); } return $this->_response; }
/** * Test generate uri with wsdl param as true */ public function testGenerateUriWithNoWsdlParam() { $param = "testModule1AllSoapAndRest:V1,testModule2AllSoapNoRest:V1"; $serviceKey = \Magento\Webapi\Model\Soap\Server::REQUEST_PARAM_SERVICES; $this->_requestMock->expects($this->any())->method('getParam')->will($this->returnValue($param)); $expectedResult = "http://magento.com/soap/storeCode?{$serviceKey}={$param}"; $actualResult = $this->_soapServer->generateUri(false); $this->assertEquals($expectedResult, urldecode($actualResult), 'URI (without WSDL param) generated is invalid.'); }
/** * Dispatch SOAP request. * * @param \Magento\Framework\App\RequestInterface $request * @return \Magento\Framework\App\ResponseInterface */ public function dispatch(\Magento\Framework\App\RequestInterface $request) { $path = $this->_pathProcessor->process($request->getPathInfo()); $this->_request->setPathInfo($path); $this->areaList->getArea($this->_appState->getAreaCode())->load(\Magento\Framework\App\Area::PART_TRANSLATE); try { if ($this->_isWsdlRequest()) { $responseBody = $this->_wsdlGenerator->generate($this->_request->getRequestedServices(), $this->_soapServer->generateUri()); $this->_setResponseContentType(self::CONTENT_TYPE_WSDL_REQUEST); $this->_setResponseBody($responseBody); } else { $this->_soapServer->handle(); } } catch (\Exception $e) { $this->_prepareErrorResponse($e); } return $this->_response; }
/** * Dispatch SOAP request. * * @param \Magento\Framework\App\RequestInterface $request * @return \Magento\Framework\App\ResponseInterface */ public function dispatch(\Magento\Framework\App\RequestInterface $request) { $path = $this->_pathProcessor->process($request->getPathInfo()); $this->_request->setPathInfo($path); $this->areaList->getArea($this->_appState->getAreaCode())->load(\Magento\Framework\App\Area::PART_TRANSLATE); try { if (!$this->_appState->isInstalled()) { throw new WebapiException(__('Magento is not yet installed')); } if ($this->_isWsdlRequest()) { $responseBody = $this->_wsdlGenerator->generate($this->_request->getRequestedServices(), $this->_soapServer->generateUri()); $this->_setResponseContentType(self::CONTENT_TYPE_WSDL_REQUEST); $this->_setResponseBody($responseBody); } else { $consumerId = $this->_oauthService->validateAccessToken($this->_getAccessToken()); $this->_request->setConsumerId($consumerId); $this->_soapServer->handle(); } } catch (\Exception $e) { $this->_prepareErrorResponse($e); } return $this->_response; }
/** * Generate SOAP fault message in XML format. * * @param string $reason Human-readable explanation of the fault * @param string $code SOAP fault code * @param array|null $details Detailed reason message(s) * @return string */ public function getSoapFaultMessage($reason, $code, $details = null) { $detailXml = $this->_generateDetailXml($details); $language = $this->getLanguage(); $detailsNamespace = !empty($detailXml) ? 'xmlns:m="' . urlencode($this->_soapServer->generateUri(true)) . '"' : ''; $reason = htmlentities($reason); $message = <<<FAULT_MESSAGE <?xml version="1.0" encoding="utf-8" ?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" {$detailsNamespace}> <env:Body> <env:Fault> <env:Code> <env:Value>env:{$code}</env:Value> </env:Code> <env:Reason> <env:Text xml:lang="{$language}">{$reason}</env:Text> </env:Reason> {$detailXml} </env:Fault> </env:Body> </env:Envelope> FAULT_MESSAGE; return $message; }