I am new with WFS and GeoServer.
My goal is to search objects on a GeoServer via WFS.
To get started, I use the documentation. I already have problems at the beginning.
The request
http://localhost/geoserver/wfs?service=wfs&
version=1.1.0&
request=GetCapabilities
shows me the following in the browser Firefox:
GeoServer Web Feature ServiceThis is the reference implementation of WFS 1.0.0 and WFS 1.1.0, supports all WFS operations including Transaction.WFSWMSGEOSERVERWFS1.1.0NONENONEThe Ancient GeographersClaudius PtolomaeusChief GeographerAlexandriaEgyptclaudius.ptolomaeus@gmail.com1.0.01.1.0text/xmlServiceIdentificationServiceProviderOperationsMetadataFeatureTypeListFilter_Capabilitiestext/xml; subtype=gml/3.1.1resultshitstext/xml; subtype=gml/3.1.1GML2KMLSHAPE-ZIPapplication/gml+xml; version=3.2application/jsonapplication/vnd.google-earth.kml xmlapplication/vnd.google-earth.kml+xmlcsvgml3gml32jsontext/xml; subtype=gml/2.1.2text/xml; subtype=gml/3.22ALLSOMEresultshitstext/xml; subtype=gml/3.1.1GML2KMLSHAPE-ZIPapplication/gml+xml; version=3.2application/jsonapplication/vnd.google-earth.kml xmlapplication/vnd.google-earth.kml+xmlcsvgml3gml32jsontext/xml; subtype=gml/2.1.2text/xml; subtype=gml/3.2text/xml; subtype=gml/3.1.1GenerateNewUseExistingReplaceDuplicateALLSOMEQueryInsertUpdateDeleteLockgml:Envelopegml:Pointgml:LineStringgml:PolygonLessThanGreaterThanLessThanEqualToGreaterThanEqualToEqualToNotEqualToLikeBetweenNullCheckabsabs_2abs_3abs_4acosAddCoveragesAffineAggregateAreaarea2AreaGridasinatanatan2attributeCountBandMergeBandSelectBarnesSurfacebetweenboundaryboundaryDimensionboundedByBoundsbufferBufferFeatureCollectionbufferWithSegmentsCategorizeceilcentroidclassifyClassifyByRangeClipCollectGeometriesCollection_AverageCollection_BoundsCollection_CountCollection_MaxCollection_MedianCollection_MinCollection_NearestCollection_SumCollection_UniqueConcatenatecontainsContourcontrastconvertconvexHullConvolveCoveragecosCountCoverageClassStatsCropCoveragecrossesdarkendateDifferencedateFormatdateParsedesaturatedifferencedimensiondisjointdisjoint3Ddistancedistance3Ddouble2boolendAngleendPointenvenvelopeEqualAreaEqualIntervalequalsExactequalsExactToleranceequalToexpexteriorRingFeatureFeatureClassStatsfloorgeometrygeometryTypegeomFromWKTgeomLengthgetGeometryNgetXgetYgetzgrayscalegreaterEqualThangreaterThanGridHeatmaphslidIEEEremainderif_then_elseinin10in2in3in4in5in6in7in8in9InclusionFeatureCollectionint2bboolint2ddoubleinteriorPointinteriorRingNInterpolateintersectionIntersectionFeatureCollectionintersectsintersects3DisClosedisCoverageisEmptyisInstanceOfisLikeisNullisometricisRingisSimpleisValidisWithinDistanceisWithinDistance3DJenksJifflejsonPointerlengthlessEqualThanlessThanlightenlistlistMultiplylogLRSGeocodeLRSMeasureLRSSegmentmaxmax_2max_3max_4minmin_2min_3min_4mincircleminimumdiameterminrectanglemixmoduloMultiplyCoveragesNearestNormalizeCoveragenotnotEqualTonumberFormatnumberFormat2numGeometriesnumInteriorRingnumPointsoctagonalenvelopeoffsetoverlapsparameterparseBooleanparseDoubleparseIntparseLongpgNearestpiPointBufferspointNPointStackerPolygonExtractionpowpropertyPropertyExistsQuantileQueryrandomRangeLookupRasterAsPointCollectionRasterZonalStatisticsRasterZonalStatistics2RecodeRectangularCliprelaterelatePatternReprojectrescaleToPixelsrintroundround_2roundDoublesaturateScaleCoveragesetCRSshadeSimplifysinSnapspinsqrtStandardDeviationstartAnglestartPointstrAbbreviatestrCapitalizestrConcatstrDefaultIfBlankstrEndsWithstrEqualsIgnoreCasestrIndexOfstringTemplatestrLastIndexOfstrLengthstrMatchesstrPositionstrReplacestrStartsWithstrStripAccentsstrSubstringstrSubstringStartstrToLowerCasestrToUpperCasestrTrimstrTrim2strURLEncodeStyleCoveragesymDifferencetantinttoDegreestoRadianstouchestoWKTTransformTransparencyFillunionUnionFeatureCollectionUniqueUniqueIntervalVectorToRasterVectorZonalStatisticsverticeswithin
I was expecting to see what features I could use here.
The request
http://localhost/geoserver/wfs?service=wfs&version=2.0.0&
request=DescribeFeatureType
shows me the following in an editor
<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wfs="http://www.opengis.net/wfs/2.0" elementFormDefault="qualified" targetNamespace="http://www.opengis.net/gml/3.2">
I expected a list of the feature types
available.
Next I tried
http://localhost/geoserver/wfs?
service=wfs&
version=2.0.0&
request=GetFeature&
typeNames=namespace:featuretype
that returned me
Unknown namespace [namespace]
And last but not least I tried with names I expected as namespace
and featuretype
http://localhost/geoserver/wfs?
service=wfs&
version=2.0.0&
request=GetFeature&
typeNames=JAN_ALKIS:flur
This tells me the following in the browser
Feature type JAN_ALKIS:flur unknown
How do I find out how to put together a WFS GetFeature query?
Edit:
The request
http://localhost/geoserver/wfs?service=wfs&
version=1.1.0&
request=GetCapabilities
shows me the following in the browser Chrome:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<wfs:WFS_Capabilities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/wfs" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ows="http://www.opengis.net/ows" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:KRE_ALKIS="KRE_ALIKS" xmlns:KRE_KANAL="KRE_KANAL" version="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs http://172.16.206.128:8080/geoserver/schemas/wfs/1.1.0/wfs.xsd" updateSequence="654">
<ows:ServiceIdentification>
<ows:Title>GeoServer Web Feature Service</ows:Title>
<ows:Abstract>
This is the reference implementation of WFS 1.0.0 and WFS 1.1.0, supports all WFS operations including Transaction.
</ows:Abstract>
<ows:Keywords>
<ows:Keyword>WFS</ows:Keyword>
<ows:Keyword>WMS</ows:Keyword>
<ows:Keyword>GEOSERVER</ows:Keyword>
</ows:Keywords>
.....
Best Answer
You need a browser that is capable of displaying XML to be able to get into this - I recommend Chrome or Firefox. Clearly your
getCapabilities
request has been striped of the tags that make it meaningful. On a local instance I get an 86kB file that starts:Which just tells me that this is a WFS, it's version 1.1.0 and if you are lucky tells you who owns this server (usually this is Claudius Ptolomaeus who is in charge of much of the worlds GeoSpatial infrastructure).
There are then sections that tell you (or a client program) what
requests
the service will answer, we can usually skip over these unless we want to do something odd. Basically, the only ones we ever care about aregetCapabilities
(which we've already used),describeFeatureType
andgetFeature
.The rest of the file is a list of available
FeatureTypes
(or layers) that we can ask questions about. For example:This gives me a name (
topp:tasmainia_roads
), hopefully some other human readable data like a title, abstract and keywords (don't hold your breath hoping for these though), a note of the Spatial Reference System (SRS or projection) the data is in (lat/lon degrees here) and finally, the WGS84 bounding box of the data set (again this might just be the whole world on lazy sites).So to simply request some data I can make a request like:
where I specify the
service
(WFS
),request
type (GetFeature
), theversion
number (1.1.0
) and thetypeName
I'm interested in (topp:tasmania_roads
) exactly as given in the capabilities document. This gives me a screen full of XML (GML to be specific).If however, we wanted to know what the "schema" or
FeatureType
of a layer was before we grabbed all the data then we could make aDescribeFeatureType
request using a URL like:Everything is exactly the same as the
GetFeature
request except therequest
which is changed toDescribeFeatureType
. This returns:Which tells us (or our client) to expect Features with two attributes "the_geom" (a MultiLineString) and "TYPE" (a String). Both attributes are optional (minOccurs=0) and could be NULL (nillable="true").
Note
In all the URLs the keywords (request, version, typeName) are case insensitive while the parameters are not - so reQueSt=WFS will work, typeName=TOPP:TASMANIA_Roads will not.