When you want to connect to a WFS server and visualize data, you need to know which data sets are available.

First, you need to create a TLcdWFSClient instance:

String serverURL = "https://sampleservices.luciad.com/wfs";
TLcdWFSClient wfsClient = TLcdWFSClient.createWFSClient(new URI(serverURL));

The client offers API to perform a GetCapabilities request:

TLcdWFSCapabilities capabilities = wfsClient.getCachedCapabilities();

The return value is a Java object representing the capabilities exposed by the server.

If we now loop over the capabilities, we can collect all available feature types layers:

List<QName> availableFeatureTypes = new ArrayList<>();
TLcdWFSFeatureTypeList featureTypeList = capabilities.getFeatureTypeList();
for (int i = 0; i < featureTypeList.getFeatureTypeCount(); i++) {
  TLcdWFSFeatureType featureType = featureTypeList.getFeatureType(i);
  availableFeatureTypes.add(featureType.getName());
}

Find below a runnable example which lists the available data sets on our sample server:

import java.net.URI;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

import javax.xml.namespace.QName;

import com.luciad.ogc.wfs.client.TLcdWFSClient;
import com.luciad.ogc.wfs.common.model.TLcdWFSCapabilities;
import com.luciad.ogc.wfs.common.model.TLcdWFSFeatureType;
import com.luciad.ogc.wfs.common.model.TLcdWFSFeatureTypeList;

class FindAvailableDataTutorial {

  public static void main(String[] args) throws Exception {
    String serverURL = "https://sampleservices.luciad.com/wfs";
    TLcdWFSClient wfsClient = TLcdWFSClient.createWFSClient(new URI(serverURL));

    TLcdWFSCapabilities capabilities = wfsClient.getCachedCapabilities();

    List<QName> availableFeatureTypes = new ArrayList<>();
    TLcdWFSFeatureTypeList featureTypeList = capabilities.getFeatureTypeList();
    for (int i = 0; i < featureTypeList.getFeatureTypeCount(); i++) {
      TLcdWFSFeatureType featureType = featureTypeList.getFeatureType(i);
      availableFeatureTypes.add(featureType.getName());
    }

    System.out.println("Available WFS feature types on " + serverURL + ": \n");
    availableFeatureTypes.stream()
                         .sorted(Comparator.comparing(QName::getLocalPart))
                         .forEach(System.out::println);
  }
}