NWB WFS i.c.m. GeoServer

Sinds enige tijd maak ik, via GeoServer, gebruik van de NWB (Wegen) WFS om straatnamen op een kaart te tonen. Onlangs kwam ik er achter dat de WFS nu fouten geeft in GeoServer, om specifieker te zijn in de GeoTools library die GeoServer gebruikt. Het lijkt er op dat er iets in de service is gewijzigd omdat deze voorheen altijd heeft gewerkt.

De fout is als volgt: java.lang.ClassCastException: java.util.HashMap cannot be cast to org.opengis.feature.simple.SimpleFeature

Na wat zoeken kwam ik bij de FAQ van GeoTools (http://docs.geotools.org/latest/userguide/library/xml/faq.html) waarop het volgende staat:

Q: For WFS why does Parser return a Map? This shows up as the following error:

ClassCastException “java.util.HashMap cannot be cast to FeatureCollection”. To understand this error please remember that the GML returned by a WFS GetFeatures request is a normal XML file, with a reference to an XML schema at the top.

For a WFS GetFeature response the schema reference is usually a DescribeFeatureType call that returns an XML Schema.

If this schema is incorrectly configured (common with MapServer) or cannot be reached (common with restricted environments) our Parser will give up guessing what is a Feature and just return the values in a HashMap.

Note If you are using the GML utility class it will perform a bit of analysis and create an ad-hoc FeatureType in order to return you Features. looking at the HashMaps returned building a feature type that matches that kind of contents building features that match that FeatureType This is similar to the approach taken by OGR; OGR figures out where the “geometry” is; and then goes up two levels and assumes those things are features. Both of these approaches are strictly a work around for a common problem of misconfigured WFS servers. Here is how to review the configuration of your WFS Server:

If you are having a problem with a HashMap being returned when you expect a Feature, you should check GetCapabilities responses for remote server e.g. with browser:

http://{URL}?SERVICE=WFS&VERSION=1.1.0&REQUEST=GetCapabilities After that, ensure that elements contain urls that actually work

In particular check that DescribeFeatureType responds with the expected XML Schema

Kan het zijn, zoals in de FAQ beschreven, dat het schema van de WFS niet juist is of iets anders in die richting?

Hoi @BasCouwenberg
Heb je een voorbeeld request waarmee je onze NWB services aanroept?
Wat ik kan zeggen is dat de containers die de NWB opsluiten niet recent hebben gewijzigd (up-time van +3 maanden), wat versta je onder ‘enige tijd’?

Het volgende request wordt in GeoServer ingericht als bron:

https://geodata.nationaalgeoregister.nl/nwbwegen/wfs?&request=GetCapabilities&service=WFS&version=1.1.0

Hiervan maakt GeoServer weer zijn eigen GetFeature requests. We gebruiken deze al jaren. Het valt ook op dat hij ontzettend traag is. Zeker vergeleken met de volgende capabilities waarbij de GetFeature requests in GeoServer snel antwoord geven:

https://geodata.nationaalgeoregister.nl/bag/wfs?&request=GetCapabilities&service=WFS&version=1.1.0

Heeft iemand een idee waarom de WFS van de nwbwegen anders (niet goed) werkt? Als ik bijvoorbeeld een DescribeFeatureType uitvoer krijg ik ook een vreemde foutmelding terwijl de WFS van de BAG wel goed werkt.

WFS NWB:
https://geodata.nationaalgeoregister.nl/nwbwegen/wfs?request=DescribeFeatureType&typeName=nwbwegen:wegvakken

Antwoord:
mapserv(): Web application error. Traditional BROWSE mode requires a TEMPLATE in the WEB section, but none was provided.

WFS BAG:
https://geodata.nationaalgeoregister.nl/bag/wfs?request=DescribeFeatureType&typeName=bag:panda_face:

Antwoord:
Het schema van het pand type.

Ha @BasCouwenberg. Er missen een aantal parameters die nodig zijn:

  • Service
  • Version

Deze doet het wel:

https://geodata.nationaalgeoregister.nl/nwbwegen/wfs?request=DescribeFeatureType&typeName=nwbwegen:wegvakken&service=WFS&version=1.0.0

HTH

De bovenstaande DescribeFeatureType heeft de volgende namespace in het antwoord: xmlns:nwbwegen=“http://nwbwegen.geonovum.nl

Als er een GetCapabilities wordt gedaan dan staat er de volgende namespace:
xmlns:nwbwegen=“http://example.org/pdok/nwbwegen

De laatste lijkt mij niet juist. Als de WFS in GeoServer wordt gebruikt dan probeert GeoServer iets met de namespace te doen en dat gaat fout.

Is het mogelijk om de GetCapabilities ook de juiste namespace terug te laten geven?