public ServiceMetadata getMetadataInfoFromWMS(String urlServer) { ServiceMetadata servMetadata = new ServiceMetadata(); try { WMSClient wms = new WMSClient(urlServer); wms.connect(null); // set server information WMSServiceInformation serviceInfo = wms.getServiceInformation(); servMetadata.setAbstractStr(serviceInfo.abstr); servMetadata.setFees(serviceInfo.fees); servMetadata.setKeywords(serviceInfo.keywords); servMetadata.setName(serviceInfo.name); servMetadata.setTitle(serviceInfo.title); servMetadata.setUrl(urlServer); servMetadata.setVersion(serviceInfo.version); // I can't get from service the accessConstraints value // servMetadata.setAccessConstraints(accessConstraints); // get layers TreeMap layers = wms.getLayers(); if (layers != null) { List<Layer> lstLayers = new ArrayList<Layer>(); Set<String> keys = layers.keySet(); for (String key : keys) { WMSLayer wmsLayer = (WMSLayer) layers.get(key); Layer layer = new Layer(); layer.setName(wmsLayer.getName()); layer.setTitle(wmsLayer.getTitle()); lstLayers.add(layer); } servMetadata.setLayers(lstLayers); } // get operations Hashtable supportedOperations = serviceInfo.getSupportedOperationsByName(); if (supportedOperations != null) { List<OperationsMetadata> lstOperations = new ArrayList<OperationsMetadata>(); Set<String> keys = supportedOperations.keySet(); for (String key : keys) { OperationsMetadata opMetadata = new OperationsMetadata(); opMetadata.setName(key); opMetadata.setUrl((String) supportedOperations.get(key)); lstOperations.add(opMetadata); } servMetadata.setOperations(lstOperations); } // get contact address ContactAddressMetadata contactAddress = null; if (StringUtils.isNotEmpty(serviceInfo.address) || StringUtils.isNotEmpty(serviceInfo.addresstype) || StringUtils.isNotEmpty(serviceInfo.place) || StringUtils.isNotEmpty(serviceInfo.country) || StringUtils.isNotEmpty(serviceInfo.postcode) || StringUtils.isNotEmpty(serviceInfo.province)) { contactAddress = new ContactAddressMetadata(); contactAddress.setAddress(serviceInfo.address); contactAddress.setAddressType(serviceInfo.addresstype); contactAddress.setCity(serviceInfo.place); contactAddress.setCountry(serviceInfo.country); contactAddress.setPostCode(serviceInfo.postcode); contactAddress.setStateProvince(serviceInfo.province); } // get contact info ContactMetadata contactMetadata = null; if (contactAddress != null || StringUtils.isNotEmpty(serviceInfo.email) || StringUtils.isNotEmpty(serviceInfo.fax) || StringUtils.isNotEmpty(serviceInfo.organization) || StringUtils.isNotEmpty(serviceInfo.personname) || StringUtils.isNotEmpty(serviceInfo.function) || StringUtils.isNotEmpty(serviceInfo.phone)) { contactMetadata = new ContactMetadata(); contactMetadata.setContactAddress(contactAddress); contactMetadata.setEmail(serviceInfo.email); contactMetadata.setFax(serviceInfo.fax); contactMetadata.setOrganization(serviceInfo.organization); contactMetadata.setPerson(serviceInfo.personname); contactMetadata.setPosition(serviceInfo.function); contactMetadata.setTelephone(serviceInfo.phone); } servMetadata.setContact(contactMetadata); } catch (Exception exc) { // Show exception in log logger.error("Exception on getMetadataInfoFromWMS", exc); throw new ServerGeoException(); } return servMetadata; }