WFS:GetFeatures POST 中的无效类型名称?

Invalid typenames in WFS:GetFeatures POST?

我试图让最简单的 WFS HTTP_POST 请求工作,针对 GeoServer WFS 端点。

此 HTTP_GET 请求有效,并且 return 符合我的预期(为清楚起见插入换行符):

http://mygeoserver.com/geoserver/ows?
    service=wfs&
    version=2.0.0&
    request=getfeature&
    count=3&
    typenames=mynamespace:myfeaturetype&
    cql_filter=dccode=%27XYZ%27

我希望这个 HTTP_POST 请求:

http://mygeoserver.com/geoserver/ows

使用此请求正文:

<GetFeature
    version="2.0.0"
    service="WFS"
    count="3"
    xmlns="http://www.opengis.net/wfs/2.0"
    xmlns:fes="http://www.opengis.net/fes/2.0"
    xmlns:gsml="http://xmlns.geosciml.org/GeoSciML-Core/3.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.opengis.net/wfs/2.0
    http://schemas.opengis.net/wfs/2.0/wfs.xsd"
    >

    <Query
        typeNames="mynamespace:myfeaturetype"
        >
        <Filter  
            xmlns="http://www.opengis.net/fes/2.0" 
            xmlns:xlink="http://www.w3.org/1999/xlink" 
            xmlns:gsml="http://xmlns.geosciml.org/GeoSciML-Core/3.2" >
            <PropertyIsEqualTo>
                <ValueReference>dccode</ValueReference>
                <Literal>XYZ</Literal>
            </PropertyIsEqualTo>
        </Filter>
    </Query>
</GetFeature>

到return一样。

相反,我得到一个错误:

    cvc-datatype-valid.1.2.3: 'mynamespace:myfeaturetype' is not a valid value of union type 'TypeNamesType'.

    cvc-attribute.3: The value 'mynamespace:myfeaturetype' of attribute 'typeNames' on element 'Query' is not valid with respect to its type, 'TypeNamesListType'.

让我陷入循环的是 HTTP_GET 中用于 typeNames 参数的相同值在 HTTP_POST.

中引发错误

问题似乎是我需要在 XML 中为 "mynamespace" 指定名称空间定义。

<Query
    typeNames="mynamespace:myfeaturetype"
    xmlns:mynamespace="http://????"
    >

我假设它在我的 GeoServer 安装中的某处可用。但是在哪里呢?

它将是您设置为工作区 mynamespace 的 URI。您可以使用 describeFeature 请求查看它。例如:

curl http://localhost:8080/geoserver/wfs\?service=wfs\&version=1.1.0\&request=DescribeFeatureType\&typeName=topp:states

给出:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:gml="http://www.opengis.net/gml" 
   xmlns:topp="http://www.openplans.org/topp" 
   xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
   elementFormDefault="qualified" 
   targetNamespace="http://www.openplans.org/topp">
  <xsd:import namespace="http://www.opengis.net/gml" schemaLocation="http://localhost:8080/geoserver/schemas/gml/3.1.1/base/gml.xsd"/>
  <xsd:complexType name="statesType">
    <xsd:complexContent>
     [....]