Getting the service-level metadata info |
SuperMap iServer defines the WMSCapabilities object type to store the service-level metadata information of WMS. The getCapabilities(String version) method of the WMS interface can get the service level metadata objects by passing in the WMS version number.
Add the following code in WMSClientSample.java to get the service-level metadata information:
package com.supermap.sample;
import com.supermap.services.components.spi.ogc.WMS;
import com.supermap.services.components.spi.ogc.WMSCapabilities;
import com.supermap.services.components.spi.ogc.WMSClient;
public class WMSClientSample {
// WMS service address
private static String strURL = "http://localhost:8090/iserver/services/map-world/wms111?";
// The user name to access the WMS service
private static String userName = null;
// The password to access the WMS service
private static String password = null;
// Construct a WMSClient instantiated object based on the WMS address, the user name and the password
private WMS wmsClient = new WMSClient(strURL, userName, password);
// Get the service-level metadata information
public WMSCapabilities getCapabilities() {
WMSCapabilities wmsCapabilities = null;
String wmsVersion = "1.1.1";
try {
wmsCapabilities = wmsClient.getCapabilities(wmsVersion);
} catch (Exception e) {
e.printStackTrace();
}
return wmsCapabilities;
}
public static void main(String[] args) {
WMSClientSample wmsClientSample = new WMSClientSample();
// Output the service title and the map title
WMSCapabilities capabilities = wmsClientSample.getCapabilities();
String wmsTitle = capabilities.serviceDescription.title;
String mapTitle = capabilities.mapTitle;
System.out.println("WMS Title is " + wmsTitle);
System.out.println("MapTitle is " + mapTitle);
}
}
Before running the WMSClientSample, you need to ensure that the service http://localhost:8090/iserver/services/map-world/wms111 has been started.
After compiling the WMSClientSample project, right-click the WMSClientSample project, and then select Run as > Java Application to run the Java application to display the feature information, as shown below, on the console.
WMS Title is WMS service published by SuperMap iServer
MapTitle is World