| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- // @usage: throw new Api_WfsException("Access Denied to Create field '{$fieldName}' in object '{$typeName}.{$pkObject}'", __LINE__, null, 'MissingFieldPermCreate', 'request');
- // <xsd:schema
- // targetNamespace="http://www.opengis.net/ogc"
- // xmlns:ogc="http://www.opengis.net/ogc"
- // xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- // elementFormDefault="qualified">
- //
- // <xsd:element name="ServiceExceptionReport">
- // <xsd:complexType>
- // <xsd:sequence>
- // <xsd:element name="ServiceException"
- // type="ogc:ServiceExceptionType"
- // minOccurs="0" maxOccurs="unbounded"/>
- // </xsd:sequence>
- // <xsd:attribute name="version" type="xsd:string" fixed="1.3.0"/>
- // </xsd:complexType>
- // </xsd:element>
- //
- // <xsd:complexType name="ServiceExceptionType">
- // <xsd:simpleContent>
- // <xsd:extension base="xsd:string">
- // <xsd:attribute name="code" type="xsd:string"/>
- // <xsd:attribute name="locator" type="xsd:string"/>
- // </xsd:extension>
- // </xsd:simpleContent>
- // </xsd:complexType>
- // </xsd:schema>
- 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();
- }
- }
|