The information in this guide is only needed if you want to perform your own WMS request, for example a
To set up a connection to a WMS service you first need to create a new WMS client:
String serverURL = "https://sampleservices.luciad.com/wms"; TLcdWMSClient wmsClient = TLcdWMSClient.createWMSClient(new URI(serverURL));
You can use one client instance for just one OGC service. Therefore, you must identify the service at construction time.
The client you just created will connect with the WMS service by retrieving its capabilities. As described in the OGC specifications, a version negotiation process will also take place to determine a commonly supported version between the web service and the web client.
When a version has been agreed, the corresponding capabilities document is cached locally. To access the document, you can
use the method
Requests are modeled by the interface
which supports (if applicable):
Key-value pair requests
You cannot instantiate these request objects directly. Instead, they are created by factory methods in the client.
The created requests are automatically initialized with the parameters
The value of the
VERSION parameter corresponds to the version agreed during the version negotiation
process upon initialization.
Each request will have a specific type of response.
The LuciadLightspeed OGC Web Client Suite offer a number of predefined response types.
The general response type
is an extension of
java.io.FilterInputStream, which adds the content type and some extra metadata to the result stream.
It is also possible to create custom requests. To support custom requests, you must override the appropriate client class, to provide access to the new requests.
Extensions can perform custom
ILcdOWSRequest implementations by invoking the protected method
Next to the request itself, the name of the operation associated with the request is required. This operation must correspond to an operation defined in the capabilities of the OGC service.
GetCapabilities is a mandatory operation supported by each OGC service.
If the operation is not supported, the request will not be performed and an
UnsupportedOperationException is thrown.
You can retrieve the list of available operations at an OGC service through the method
which returns a list of
The default implementations of
ILcdOWSRequest for the WMS service are:
TLcdWMSGetCapabilitiesRequest: represents a
TLcdWMSGetFeatureInfoRequest: represents a
TLcdWMSGetMapRequest: represents a
TLcdWMSDescribeLayerRequest: represents a
TLcdWMSGetLegendGraphicRequest: represents a
Use the factory methods in
TLcdWMSClient to create these request objects.
// Create a GetCapabilities request TLcdWMSGetCapabilitiesRequest getCapabilitiesRequest = wmsClient.createGetCapabilitiesRequest(); // Create a GetFeatureInfo request TLcdWMSGetFeatureInfoRequest getFeatureInfoRequest = wmsClient.createGetFeatureInfoRequest(); // Create a GetMap request TLcdWMSGetMapRequest getMapRequest = wmsClient.createGetMapRequest(); // Create a GetLegendGraphic request TLcdWMSGetLegendGraphicRequest getLegendGraphicRequest = wmsClient.createGetLegendGraphicRequest(); // Create a DescribeLayer request TLcdWMSDescribeLayerRequest describeLayerRequest = wmsClient.createDescribeLayerRequest();
GetMap request supports XML encoding in addition to key-value pair encoding.
The reason for this is that the XML encoding is not specified for the other requests.
After the configuration of the request, you can send it to the WMS.
For each pre-defined request, a separate method is defined in
TLcdWMSClient that performs the request.
If a service exception is returned by the server, the exception is decoded and thrown as a
Otherwise the result is returned.
The following code snippet illustrates how to send the requests:
// Send a GetCapabilities request ALcdOGCWMSCapabilities capabilities = wmsClient.getCapabilities(getCapabilitiesRequest); // Send a GetFeatureInfo request TLcdOWSInputStream getFeatureInfoResult = wmsClient.getFeatureInfo(getFeatureInfoRequest); // Send a GetMap request TLcdOWSInputStream getMapResult = wmsClient.getMap(getMapRequest); // Send a GetLegendGraphic request TLcdOWSInputStream getLegendGraphicResult = wmsClient.getLegendGraphic(getLegendGraphicRequest); // Send a DescribeLayer request TLcdOWSInputStream describeLayerResult = wmsClient.describeLayer(describeLayerRequest);
The pre-defined WMS response types are:
The list of available operations at a WMS service can be retrieved through the method
which returns a list of
By default, it reads the operations defined in the 'Capability/Request' section of the capabilities.
If a WMS service uses other sections to define supplementary operations, in the vendor-specific section for example, this
method can be overridden to take these into account.
If the server uses WMS version 1.3.0, it can also define extra operations by providing an extension schema of the WMS schema in its capabilities. If this is done correctly, the client decodes these operations automatically and adds them to the list.