WFS_1_1_0_Protocol implements WFSProtocol { public WFSResponse issueGetFeaturePOST(final GetFeature request) throws IOException { if (!supportsOperation(WFSOperationType.GET_FEATURE, true)) { throw new UnsupportedOperationException( "The server does not support GetFeature for HTTP method POST"); } URL postURL = getOperationURL(WFSOperationType.GET_FEATURE, true); if(request instanceof GetFeatureQueryAdapter) { GetFeatureQueryAdapter adapter = (GetFeatureQueryAdapter) request; if(adapter.getVendorParameter() != null) { String url = postURL.toString(); if ((url == null) || !url.endsWith("?")) { url += "?"; } boolean first = true; for (Map.Entry<String, String> entry : adapter.getVendorParameter().entrySet()) { if(first) { first = false; } else { url += "&"; } url += entry.getKey() + "=" + URLEncoder.encode(entry.getValue(), "UTF-8"); } postURL = new URL(url); } } RequestComponents reqParts = strategy.createGetFeatureRequest(this, request); GetFeatureType serverRequest = reqParts.getServerRequest(); Encoder encoder = new Encoder(strategy.getWfsConfiguration()); String typeName = reqParts.getKvpParameters().get("TYPENAME"); QName fullName = getFeatureTypeName(typeName); String prefix = fullName.getPrefix(); String namespace = fullName.getNamespaceURI(); if (!XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) { encoder.getNamespaces().declarePrefix(prefix, namespace); } WFSResponse response = issuePostRequest(serverRequest, postURL, encoder); return response; } WFS_1_1_0_Protocol(InputStream capabilitiesReader, HTTPClient http,
            Charset defaultEncoding, WFSStrategy strategy); void setStrategy(WFSStrategy strategy); Version getServiceVersion(); String getServiceTitle(); String getServiceAbstract(); Set<String> getServiceKeywords(); URI getServiceProviderUri(); Set<String> getSupportedGetFeatureOutputFormats(); Set<String> getSupportedOutputFormats(String typeName); Set<QName> getFeatureTypeNames(); QName getFeatureTypeName(String typeName); FilterCapabilities getFilterCapabilities(); boolean supportsOperation(WFSOperationType operation, boolean post); URL getOperationURL(WFSOperationType operation, boolean post); String getFeatureTypeTitle(String typeName); String getFeatureTypeAbstract(String typeName); ReferencedEnvelope getFeatureTypeWGS84Bounds(String typeName); String getDefaultCRS(String typeName); Set<String> getSupportedCRSIdentifiers(String typeName); Set<String> getFeatureTypeKeywords(String typeName); URL getDescribeFeatureTypeURLGet(String typeName); WFSResponse describeFeatureTypeGET(String typeName, String outputFormat); WFSResponse describeFeatureTypePOST(String typeName, String outputFormat); WFSResponse issueGetFeatureGET(final GetFeature request); WFSResponse issueGetFeaturePOST(final GetFeature request); void dispose(); static void encode(final EObject request, final Configuration configuration,
            final OutputStream out, final Charset charset); String getDefaultOutputFormat(WFSOperationType operation); Filter[] splitFilters(Filter filter); @Override SimpleFeatureType issueDescribeFeatureTypeGET(final String prefixedTypeName,
            CoordinateReferenceSystem crs);  }
@Test public void testIssueGetFeature_POST() throws IOException, ParserConfigurationException, SAXException { final InputStream responseContent = TestData.openStream(this, GEOS_ARCHSITES.DATA); final TestHttpResponse httpResponse; final String defaultWfs11OutputFormat = "text/xml; subtype=gml/3.1.1"; httpResponse = new TestHttpResponse(defaultWfs11OutputFormat, "UTF-16", responseContent); TestHttpProtocol mockHttp = new TestHttpProtocol(httpResponse); createTestProtocol(GEOS_ARCHSITES.CAPABILITIES, mockHttp, new GeoServerStrategy()); Query query = new Query(GEOS_ARCHSITES.FEATURETYPENAME); GetFeature getFeature = new GetFeatureQueryAdapter(query, defaultWfs11OutputFormat, "EPSG:4326", ResultType.RESULTS); WFSResponse response; response = wfs.issueGetFeaturePOST(getFeature); assertNotNull(response); assertEquals(defaultWfs11OutputFormat, response.getContentType()); assertNotNull(response.getInputStream()); assertEquals(Charset.forName("UTF-16"), response.getCharacterEncoding()); assertEquals("text/xml", mockHttp.postCallbackContentType); Document dom; String issuedRequest; { ByteArrayOutputStream out = mockHttp.postCallbackEncodedRequestBody; issuedRequest = out.toString(); System.out.println("Issued request: " + issuedRequest); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder docBuilder = dbf.newDocumentBuilder(); dom = docBuilder.parse(new ByteArrayInputStream(out.toByteArray())); } String expectedNsDecl = "xmlns:sf=\"" + GEOS_ARCHSITES.TYPENAME.getNamespaceURI() + "\""; assertTrue(issuedRequest, issuedRequest.contains(expectedNsDecl)); Element root = dom.getDocumentElement(); assertEquals(WFS.GetFeature.getLocalPart(), root.getLocalName()); assertEquals(WFS.NAMESPACE, root.getNamespaceURI()); }