Files
2025-03-12 17:06:23 +01:00

32 lines
1.3 KiB
PHP

public function executeSoap()
{
if (!stWebApi::isEnabled())
{
$i18n = $this->getContext()->getI18N();
$this->setFlash('error', $i18n->__('Musisz włączyć webapi', null, 'stWebApiBackend'), false);
$this->getResponse()->setStatusCode(503);
return $this->forward('stWebApiBackend', 'config');
}
$config = stConfig::getInstance('stWebApiBackend');
if ($config->get('ssl', false) && !$this->getRequest()->isSecure()) throw new SoapFault('SSL', 'Please try via SSL.');
$this->setLayout(false);
$response = $this->getResponse();
$response->setContentType( "text/xml" );
if ($this->hasRequestParameter('wsdl')) {
return $this->renderText(trim($this->getRenderPartial('webapi_wsdl')));
} else {
ini_set("soap.wsdl_cache_enabled",0);
$WSDLFile = $this->getController()->genUrl('<?php echo $this->getModuleName() ?>/soap', true);
$soap = new SoapServer($WSDLFile.'?wsdl');
$soap->setClass( "<?php echo $this->getModuleName() ?>WebApi");
ob_start();
$soap->handle();
return $this->renderText(ob_get_clean());
}
}