//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
class Api_WfsException extends Exception {
public $wfsCode = '';
public $wfsLocator = '';
public function __construct($message, $code = 0, Exception $previous = null, $wfsCode = '', $wfsLocator = '') {
$this->wfsCode = $wfsCode;
$this->wfsLocator = $wfsLocator;
parent::__construct($message, $code, $previous);
}
public function generateResponseXml() {
$xmlWriter = new XMLWriter();
if (!$xmlWriter) throw new HttpException("Error no XMLWriter", 404);
// $xmlWriter->openUri('php://output');
$xmlWriter->openMemory();
$xmlWriter->setIndent(true);
$xmlWriter->startDocument('1.0','UTF-8');
$xmlWriter->startElement('ServiceExceptionReport');
{
$xmlWriter->writeAttribute('xmlns', 'http://www.opengis.net/ogc');
$xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$xmlWriter->writeAttribute('xsi:schemaLocation', 'http://www.opengis.net/ogc http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd');
$xmlWriter->writeAttribute('version', '1.2.0');
$xmlWriter->startElement('ServiceException');
{
if ($this->wfsCode) $xmlWriter->writeAttribute('code', $this->wfsCode);
if ($this->wfsLocator) $xmlWriter->writeAttribute('locator', $this->wfsLocator);
$xmlWriter->text($this->message);
}
$xmlWriter->endElement();// ServiceException
}
$xmlWriter->endElement();// ServiceExceptionReport
$xmlWriter->endDocument();
return $xmlWriter->outputMemory(true);
}
public function sendResponseXml() {
header('Content-type: application/xml');
echo $this->generateResponseXml();
}
}