Index: modules/plugin/wfs/src/main/java/org/geotools/data/wfs/WFSDataStore.java =================================================================== --- modules/plugin/wfs/src/main/java/org/geotools/data/wfs/WFSDataStore.java (revision 29131) +++ modules/plugin/wfs/src/main/java/org/geotools/data/wfs/WFSDataStore.java (working copy) @@ -213,20 +213,38 @@ private void findCapabilities(URL host) throws SAXException, IOException { - // TODO support using POST for getCapabilities - Object t = null; Map hints = new HashMap(); hints.put(DocumentFactory.VALIDATION_HINT, Boolean.FALSE); - try{ - HttpURLConnection hc = getConnection(host,auth,false); + + if( (protocol & GET_PROTOCOL) == GET_PROTOCOL ) { + HttpURLConnection hc = getConnection(createGetCapabilitiesRequest(host),auth,false); InputStream is = getInputStream(hc); t = DocumentFactory.getInstance(is, hints, WFSDataStoreFactory.logger.getLevel()); - }catch(Throwable e){ - HttpURLConnection hc = getConnection(createGetCapabilitiesRequest(host),auth,false); + } + + if( (false == (t instanceof WFSCapabilities)) && ((protocol & POST_PROTOCOL) == POST_PROTOCOL) ) { + HttpURLConnection hc = getConnection(host,auth,true); + + // write request + Writer osw = getOutputStream(hc); + hints.put(DocumentWriter.BASE_ELEMENT, + WFSSchema.getInstance().getElements()[0]); // GetCapabilities + + try { + DocumentWriter.writeDocument( (Object)null, WFSSchema.getInstance(), osw, hints ); + } catch (OperationNotSupportedException e) { + WFSDataStoreFactory.logger.warning(e.getMessage()); + throw new SAXException(e); + } + + osw.flush(); + osw.close(); + InputStream is = getInputStream(hc); t = DocumentFactory.getInstance(is, hints, WFSDataStoreFactory.logger.getLevel()); } + if (t instanceof WFSCapabilities) { capabilities = (WFSCapabilities) t; } else {