Package org.geotools.data.ows

Examples of org.geotools.data.ows.HTTPClient


        if (finalURL.getHost() == null) {
            // System.out.prinln("Poor WMS-C configuration - no host provided by "+ finalURL );
            throw new NullPointerException("No host provided by " + finalURL); //$NON-NLS-1$
        }

        final HTTPClient httpClient = server.getHTTPClient();
        final HTTPResponse httpResponse;

        if (request.requiresPost()) {

            final String postContentType = request.getPostContentType();

            ByteArrayOutputStream out = new ByteArrayOutputStream();
            request.performPostOutput(out);
            InputStream in = new ByteArrayInputStream(out.toByteArray());

            try {
                httpResponse = httpClient.post(finalURL, in, postContentType);
            } finally {
                in.close();
            }
        } else {
            httpResponse = httpClient.get(finalURL);
        }

        return httpResponse;
    }
View Full Code Here


     *            the relative path under {@code test-data} for the file containing the
     *            WFS_Capabilities document.
     */
    public static <T extends WFSStrategy> T createTestProtocol(String capabilitiesFileName, T real)
            throws Exception {
        HTTPClient http = new SimpleHttpClient();
        return createTestProtocol(capabilitiesFileName, http, real);
    }
View Full Code Here

                throw new IOException(
                        "Cannot define only one of USERNAME or PASSWORD, must define both or neither");
            }
        }

        final HTTPClient http = new SimpleHttpClient();// new MultithreadedHttpClient();
        // TODO: let HTTPClient be configured for gzip
        // http.setTryGzip(tryGZIP);
        http.setUser(config.getUser());
        http.setPassword(config.getPassword());
        int timeoutMillis = config.getTimeoutMillis();
        http.setConnectTimeout(timeoutMillis / 1000);

        final URL capabilitiesURL = (URL) URL.lookUp(params);

        // WFSClient performs version negotiation and selects the correct strategy
        WFSClient wfsClient;
View Full Code Here

     *            the relative path under {@code test-data} for the file containing the
     *            WFS_Capabilities document.
     * @throws IOException
     */
    public static void createTestProtocol(String capabilitiesFileName) throws IOException {
        HTTPClient http = new SimpleHttpClient();
        createTestProtocol(capabilitiesFileName, http);
    }
View Full Code Here

        HTTPClient http = new SimpleHttpClient();
        createTestProtocol(capabilitiesFileName, http);
    }

    public static void createTestProtocol(String capabilitiesFileName, WFSStrategy strategy) throws IOException {
        HTTPClient http = new SimpleHttpClient();
        createTestProtocol(capabilitiesFileName, http, strategy);
    }
View Full Code Here

        } catch (IOException e) {
            assertTrue(true);
        }
        try {
            InputStream badData = new ByteArrayInputStream(new byte[1024]);
            HTTPClient connFac = new SimpleHttpClient();
            new WFS_1_1_0_Protocol(badData, connFac, null, null);
            fail("Excpected IOException as a capabilities document was not provided");
        } catch (IOException e) {
            assertTrue(true);
        }
View Full Code Here

        return client;
    }

    private WFSClient newClient(String resource) throws IOException, ServiceException {
        URL capabilitiesURL = WFSTestData.url(resource);
        HTTPClient httpClient = new SimpleHttpClient();

        WFSClient client = new WFSClient(capabilitiesURL, httpClient, config);
        return client;
    }
View Full Code Here

     * @param key
     * @return
     */
    private String callWebService(String key) {
        String url = webServiceUrl.replace("{key}", key);
        HTTPClient client = getHttpClient();

        client.setConnectTimeout(connectTimeout);
        client.setReadTimeout(readTimeout);
        try {
            LOGGER.log(
                    Level.FINE,
                    "Issuing request to authkey webservice: " + url);
            HTTPResponse response = client.get(new URL(url));
            BufferedReader reader = null;
            InputStream responseStream = response.getResponseStream();
            StringBuilder result = new StringBuilder();
            try {
                reader = new BufferedReader(new InputStreamReader(responseStream));
View Full Code Here

            WebMapServer wms = wmsCache.get(id);
            if (wms == null) {
                synchronized (wmsCache) {
                    wms = wmsCache.get(id);
                    if (wms == null) {
                        HTTPClient client = getHTTPClient(info);
                        String capabilitiesURL = info.getCapabilitiesURL();
                        URL serverURL = new URL(capabilitiesURL);
                        wms = new WebMapServer(serverURL, client);
                       
                        wmsCache.put(id, wms);
View Full Code Here

        String capabilitiesURL = info.getCapabilitiesURL();
       
        // check for mock bindings. Since we are going to run this code in production as well,
        // guard it so that it only triggers if the MockHttpClientProvider has any active binding
        if(TestHttpClientProvider.testModeEnabled() && capabilitiesURL.startsWith(TestHttpClientProvider.MOCKSERVER)) {
            HTTPClient client = TestHttpClientProvider.get(capabilitiesURL);
            return client;
        }
       
        HTTPClient client;
        if (info.isUseConnectionPooling()) {
            client = new MultithreadedHttpClient();
            if (info.getMaxConnections() > 0) {
                int maxConnections = info.getMaxConnections();
                MultithreadedHttpClient mtClient = (MultithreadedHttpClient) client;
                mtClient.setMaxConnections(maxConnections);
            }
        } else {
            client = new SimpleHttpClient();
        }
        String username = info.getUsername();
        String password = info.getPassword();
        int connectTimeout = info.getConnectTimeout();
        int readTimeout = info.getReadTimeout();
        client.setUser(username);
        client.setPassword(password);
        client.setConnectTimeout(connectTimeout);
        client.setReadTimeout(readTimeout);
       
        return client;
    }
View Full Code Here

TOP

Related Classes of org.geotools.data.ows.HTTPClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.