当 WFS 处理请求时遇到错误,或是收到一个不可识别的请求,WFS 将生成一个 XML 文档,用于指明有错误发生。

OGC-exception.xsd 如下:

<?xml version="1.0" encoding="UTF-8"?>

<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:annotation>

            <xsd:documentation>

                The ServiceExceptionReport element contains one

                or more ServiceException elements that describe

                a service exception.

            </xsd:documentation>

        </xsd:annotation>

        <xsd:complexType>

            <xsd:sequence>

                <xsd:element name="ServiceException"

                             type="ogc:ServiceExceptionType"

                             minOccurs="0" maxOccurs="unbounded">

                    <xsd:annotation>

                        <xsd:documentation>

                            The Service exception element is used to describe

                            a service exception.

                        </xsd:documentation>

                    </xsd:annotation>

                </xsd:element>

            </xsd:sequence>

            <xsd:attribute name="version" type="xsd:string" fixed="1.2.0"/>

        </xsd:complexType>

    </xsd:element>

 

    <xsd:complexType name="ServiceExceptionType">

        <xsd:annotation>

            <xsd:documentation>

                The ServiceExceptionType type defines the ServiceException

                element. The content of the element is an exception message

                that the service wished to convey to the client application.

            </xsd:documentation>

        </xsd:annotation>

        <xsd:simpleContent>

            <xsd:extension base="xsd:string">

                <xsd:attribute name="code"type="xsd:string">

                    <xsd:annotation>

                        <xsd:documentation>

                            A service may associate a code with an exception

                            by using the code attribute.

                        </xsd:documentation>

                    </xsd:annotation>

                </xsd:attribute>

                <xsd:attribute name="locator"type="xsd:string">

                    <xsd:annotation>

                        <xsd:documentation>

                            The locator attribute may be used by a service to

                            indicate to a client where in the client's request

                            an exception was encountered. If the request included

                            a 'handle' attribute, this may be used to identify the

                            offending component of the request. Otherwise the

                            service may try to use other means to locate the

                            exception such as line numbers or byte offset from the

                            begining of the request, etc...

                        </xsd:documentation>

                    </xsd:annotation>

                </xsd:attribute>

            </xsd:extension>

        </xsd:simpleContent>

    </xsd:complexType>

</xsd:schema>

<ServiceExceptionReport>元素可以包含一个或多个 WFS 处理异常。必须使用属性 version 来表示服务异常报告 Schema 的版本。对于 WFS 1.0.0,该值固定为“1.2.0”。

单个异常信息包含在<ServiceException>元素中。可选的 code 属性用来把异常代码与相应的信息联系在一起。可选的 locator 属性可以用来指出异常是在生成异常的请求中的哪个部分发生的。OGC-exception.xsd 中定义了许多元素,其中包括 handle 属性。handle 属性被用来联系元素和它的助记名。如果 handle 属性存在,它的值将被<ServiceException>元素的 locator 属性报告,如果 handle 属性没有被指定,WFS 将尝试用其他的方法来定位错误,如用行号等方法。

示例,以下是一个异常报告的例子。这个异常报告表明第一个插入语句失败,因为在请求中缺少了 XML 关闭标签。

<?xmlversion="1.0"?>

<ServiceExceptionReport

    version="1.2.0"

    xmlns="http://www.opengis.net/ogc"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xsi:schemaLocation="http://www.opengis.net/ogc../wfs/1.0.0/OGC-exception.xsd">

    <ServiceException code="999" locator="INSERTSTMT01">

        parse error: missing closing tag for element WKB_GEOM

    </ServiceException>

</ServiceExceptionReport>