Sorry for not replying before, I'm not sure I saw that email.
Anyway, first construct a WFSDataStore
Map<String, Object> params = new HashMap<>();
params.put(WFSDataStoreFactory.URL.key, baseURL);
if (auth) {
params.put(WFSDataStoreFactory.USERNAME.key, user);
params.put(WFSDataStoreFactory.PASSWORD.key, passwd);
}
// params.put(WFSDataStoreFactory.WFS_STRATEGY.key, "mapserver");
datastore = DataStoreFinder.getDataStore(params);
Then simply ask for the typeNames
String[] names = datastore.getTypeNames();
and then for any name you can grab a featureSource
SimpleFeatureSource source = datastore.getFeatureSource(name);
and features:
SimpleFeatureCollection features = source.getFeatures(query);
Hope that helps
Ian
On 7 January 2018 at 20:21, Gabriella Turek <[email protected]>
wrote:
> Hi all, I am sending this again as I did not get any replies before Xmas.
>
> I am trying to implement a WFS service client in our app, but I can’t
> figure out how to get a list of available layers from the initial
> getCapabilities request.
>
> Something akin to what one can do for WMS:
>
> WebMapServer wms = null;
>
> try {
>
> wms = new WebMapServer(url);
>
> WMSCapabilities capabilities = wms.getCapabilities();
>
> Layer[] layers = WMSUtils.getNamedLayers(capabilities);
>
> if (layers == null || layers.length == 0) {
>
> return "the server does not provide any layers.";
>
> }
>
> } catch (Exception e) {}
>
>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> GeoTools-GT2-Users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>
--
Ian Turton
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users