我正在尝试使用最简单的WFS HTTP_POST请求来对抗GeoServer WFS端点。
此HTTP_GET请求有效,并返回我期望的内容(为了清晰起见,插入换行符):
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>
返回相同的内容。
相反,我收到错误:
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安装中的某个地方。但在哪里?
答案 0 :(得分:1)
它将是您设置为工作空间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>
[....]