GeoServer使用REST API获取存储仓库列表的方法

创建日期:2025-01-27
更新日期:2025-01-27

在GeoServer域名和端口后面添加以下参数即可。

/geoserver/wfs?request=ListStoredQueries&service=wfs&version=2.0.0

如果GeoServer后台管理界面地址是:

http://127.0.0.1:8080/geoserver/web/

则使用以下地址可以获取所有存储仓库:

http://127.0.0.1:8080/geoserver/wfs?request=ListStoredQueries&service=wfs&version=2.0.0

GeoServer会返回一个xml文件。

<?xml
version="1.0" encoding="UTF-8"?>
<wfs:ListStoredQueriesResponse xmlns:huangdao="http://127.0.0.1:8080/" xmlns:sf="http://www.openplans.org/spearfish" xmlns:ne="https://www.naturalearthdata.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tiger="http://www.census.gov" xmlns:topp="http://www.openplans.org/topp" xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://127.0.0.1:8080/geoserver/schemas/wfs/2.0/wfs.xsd">
    <wfs:StoredQuery id="urn:ogc:def:query:OGC-WFS::GetFeatureById">
        <wfs:Title xml:lang="en">Get feature by identifier</wfs:Title>
        <wfs:ReturnFeatureType>tiger:giant_polygon</wfs:ReturnFeatureType>
        <wfs:ReturnFeatureType>tiger:poi</wfs:ReturnFeatureType>
        <wfs:ReturnFeatureType>tiger:poly_landmarks</wfs:ReturnFeatureType>
        <wfs:ReturnFeatureType>tiger:tiger_roads</wfs:ReturnFeatureType>
        <wfs:ReturnFeatureType>topp:states</wfs:ReturnFeatureType>
        <wfs:ReturnFeatureType>topp:tasmania_cities</wfs:ReturnFeatureType>
        <wfs:ReturnFeatureType>topp:tasmania_roads</wfs:ReturnFeatureType>
        <wfs:ReturnFeatureType>topp:tasmania_state_boundaries</wfs:ReturnFeatureType>
        <wfs:ReturnFeatureType>topp:tasmania_water_bodies</wfs:ReturnFeatureType>
        <wfs:ReturnFeatureType>sf:archsites</wfs:ReturnFeatureType>
        <wfs:ReturnFeatureType>sf:bugsites</wfs:ReturnFeatureType>
        <wfs:ReturnFeatureType>sf:restricted</wfs:ReturnFeatureType>
        <wfs:ReturnFeatureType>sf:roads</wfs:ReturnFeatureType>
        <wfs:ReturnFeatureType>sf:streams</wfs:ReturnFeatureType>
        <wfs:ReturnFeatureType>ne:boundary_lines</wfs:ReturnFeatureType>
        <wfs:ReturnFeatureType>ne:coastlines</wfs:ReturnFeatureType>
        <wfs:ReturnFeatureType>ne:countries</wfs:ReturnFeatureType>
        <wfs:ReturnFeatureType>ne:disputed_areas</wfs:ReturnFeatureType>
        <wfs:ReturnFeatureType>ne:populated_places</wfs:ReturnFeatureType>
    </wfs:StoredQuery>
</wfs:ListStoredQueriesResponse>