Example usage for org.apache.http.client HttpClient getParams

List of usage examples for org.apache.http.client HttpClient getParams

Introduction

In this page you can find the example usage for org.apache.http.client HttpClient getParams.

Prototype

@Deprecated
HttpParams getParams();

Source Link

Document

Obtains the parameters for this client.

Usage

From source file:com.gorillalogic.monkeytalk.ant.RunTask.java

private String sendFormPost(String url, File proj, Map<String, String> additionalParams) throws IOException {

    HttpClient base = new DefaultHttpClient();
    SSLContext ctx = null;//from   w w w  .j  a va  2 s  . c o  m

    try {
        ctx = SSLContext.getInstance("TLS");
    } catch (NoSuchAlgorithmException ex) {
        log("exception in sendFormPost():");
    }

    X509TrustManager tm = new X509TrustManager() {
        @Override
        public X509Certificate[] getAcceptedIssuers() {
            return null;
        }

        @Override
        public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType)
                throws java.security.cert.CertificateException {
        }

        @Override
        public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType)
                throws java.security.cert.CertificateException {
        }
    };

    try {
        ctx.init(null, new TrustManager[] { tm }, null);
    } catch (KeyManagementException ex) {
        log("exception in sendFormPost():");
    }

    SSLSocketFactory ssf = new SSLSocketFactory(ctx);
    ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
    ClientConnectionManager ccm = base.getConnectionManager();
    SchemeRegistry sr = ccm.getSchemeRegistry();
    sr.register(new Scheme("https", ssf, 443));

    HttpClient client = new DefaultHttpClient(ccm, base.getParams());
    try {
        HttpPost post = new HttpPost(url);

        MultipartEntity multipart = new MultipartEntity();
        for (String key : additionalParams.keySet())
            multipart.addPart(key, new StringBody(additionalParams.get(key), Charset.forName("UTF-8")));

        if (proj != null) {
            multipart.addPart("uploaded_file", new FileBody(proj));
        }

        post.setEntity(multipart);

        HttpResponse resp = client.execute(post);

        HttpEntity out = resp.getEntity();

        InputStream in = out.getContent();
        return FileUtils.readStream(in);
    } catch (Exception ex) {
        throw new IOException("POST failed", ex);
    } finally {
        try {
            client.getConnectionManager().shutdown();
        } catch (Exception ex) {
            // ignore
        }
    }
}

From source file:com.owncloud.android.authentication.AuthenticatorActivity.java

public void Reguser(View view) {
    String passwordva2 = mPasswordInput2.getText().toString().trim();
    String passwordva1 = mPasswordInput.getText().toString().trim();
    final String username = mUsernameInput.getText().toString().trim();
    String loc = locationSpinner.getSelectedItem().toString();
    locationSpinner.setOnItemSelectedListener(this);

    final String str1 = mHostUrlInput.getText().toString();
    if (passwordva1.equals("") || passwordva2.equals("") || username.equals("")) {
        Toast.makeText(getApplicationContext(), "One or more of required fields not entered",
                Toast.LENGTH_SHORT).show();
    } else if (!passwordva1.equals(passwordva2)) {
        mPasswordInput.setText("");
        mPasswordInput2.setText("");
        Toast.makeText(getApplicationContext(), "The two passwords do not match. Please reenter the passwords",
                Toast.LENGTH_LONG).show();

    } else {// w  ww  . j  av  a2 s. c  om
        //username = username + "@" + loc;
        final ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("regname", username));
        params.add(new BasicNameValuePair("regpass1", passwordva1));
        params.add(new BasicNameValuePair("regpass2", passwordva2));
        // Log.d("sdn object ",params.toString());
        Log.d("new server ", str1);
        Runnable runnable = new Runnable() {
            @Override
            public void run() {

                HttpPost post = new HttpPost("http://" + str1 + "/androiduserreg.php");

                HttpEntity entity;
                try {
                    entity = new UrlEncodedFormEntity(params, "utf-8");
                    HttpClient client = new DefaultHttpClient();
                    post.setEntity(entity);
                    client.getParams().setParameter(CoreProtocolPNames.USER_AGENT,
                            System.getProperty("http.agent"));
                    post.setHeader("User-Agent", "Android-ownCloud");
                    HttpResponse response = client.execute(post);

                    if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                        HttpEntity entityresponse = response.getEntity();
                        String jsonentity = EntityUtils.toString(entityresponse);
                        final JSONObject jsonObject = new JSONObject(jsonentity);

                        String registerUserReply = jsonObject.getString("reply");

                        if (registerUserReply.equals(REGISTER_USER_SUCCESS)) {
                            final String location_returned = jsonObject.getString("location");
                            runOnUiThread(new Runnable() {
                                public void run() {
                                    if (!location_returned.equals(location)) {
                                        Log.d("location returned ", location_returned);
                                        Toast.makeText(getApplicationContext(),
                                                "Account created and your login id is " + location_returned,
                                                Toast.LENGTH_LONG).show();
                                    }

                                }
                            });
                            Intent i = getBaseContext().getPackageManager()
                                    .getLaunchIntentForPackage(getBaseContext().getPackageName());
                            i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                            startActivity(i);
                        } else if (registerUserReply.equals(REGISTER_USER_ALREADY_EXISTS)) {

                            runOnUiThread(new Runnable() {
                                public void run() {
                                    Toast.makeText(getApplicationContext(),
                                            "Username already exists on the server, try a different one",
                                            Toast.LENGTH_SHORT).show();

                                }
                            });
                        } else {
                            runOnUiThread(new Runnable() {
                                public void run() {
                                    Toast.makeText(getApplicationContext(),
                                            "Unable to create account, please try after sometime",
                                            Toast.LENGTH_SHORT).show();

                                }
                            });
                        }

                    }
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (JSONException e) {
                    e.printStackTrace();
                }

            }
        };
        new Thread(runnable).start();
    }
}

From source file:net.fluidnexus.FluidNexusAndroid.services.NexusServiceThread.java

/**
 * Start the listeners for zeroconf services
 *///from w ww . ja  v  a2s  .com
public void doStateNone() {
    if (wifiManager.getWifiState() == wifiManager.WIFI_STATE_ENABLED) {
        Cursor c = messagesProviderHelper.publicMessages();

        while (c.isAfterLast() == false) {
            String message_hash = c.getString(c.getColumnIndex(MessagesProviderHelper.KEY_MESSAGE_HASH));
            boolean result = checkHash(message_hash);

            if (!result) {
                try {
                    JSONObject message = new JSONObject();
                    message.put("message_title",
                            c.getString(c.getColumnIndex(MessagesProviderHelper.KEY_TITLE)));
                    message.put("message_content",
                            c.getString(c.getColumnIndex(MessagesProviderHelper.KEY_CONTENT)));
                    message.put("message_hash",
                            c.getString(c.getColumnIndex(MessagesProviderHelper.KEY_MESSAGE_HASH)));
                    message.put("message_type", c.getInt(c.getColumnIndex(MessagesProviderHelper.KEY_TYPE)));
                    message.put("message_time", c.getFloat(c.getColumnIndex(MessagesProviderHelper.KEY_TIME)));
                    message.put("message_received_time",
                            c.getFloat(c.getColumnIndex(MessagesProviderHelper.KEY_RECEIVED_TIME)));
                    message.put("message_priority",
                            c.getInt(c.getColumnIndex(MessagesProviderHelper.KEY_PRIORITY)));

                    String attachment_path = c
                            .getString(c.getColumnIndex(MessagesProviderHelper.KEY_ATTACHMENT_PATH));

                    //String serializedMessage = message.toString();

                    // First, get our nonce
                    consumer = new CommonsHttpOAuthConsumer(key, secret);
                    consumer.setTokenWithSecret(token, token_secret);
                    HttpPost nonce_request = new HttpPost(NEXUS_NONCE_URL);
                    consumer.sign(nonce_request);
                    HttpClient client = new DefaultHttpClient();
                    String response = client.execute(nonce_request, new BasicResponseHandler());
                    JSONObject object = new JSONObject(response);
                    String nonce = object.getString("nonce");

                    // Then, take our nonce and key and put them in the message
                    message.put("message_nonce", nonce);
                    message.put("message_key", key);

                    // Setup our multipart entity
                    MultipartEntity entity = new MultipartEntity();

                    // Deal with file attachment
                    if (!attachment_path.equals("")) {
                        File file = new File(attachment_path);
                        ContentBody cbFile = new FileBody(file);
                        entity.addPart("message_attachment", cbFile);

                        // add the original filename to the message
                        message.put("message_attachment_original_filename", c.getString(
                                c.getColumnIndex(MessagesProviderHelper.KEY_ATTACHMENT_ORIGINAL_FILENAME)));
                    }

                    String serializedMessage = message.toString();
                    ContentBody messageBody = new StringBody(serializedMessage);
                    entity.addPart("message", messageBody);

                    HttpPost message_request = new HttpPost(NEXUS_MESSAGE_URL);
                    message_request.setEntity(entity);

                    client = new DefaultHttpClient();
                    client.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);

                    response = client.execute(message_request, new BasicResponseHandler());
                    object = new JSONObject(response);
                    boolean message_result = object.getBoolean("result");

                    if (message_result) {
                        ContentValues values = new ContentValues();
                        values.put(MessagesProviderHelper.KEY_MESSAGE_HASH, message_hash);
                        values.put(MessagesProviderHelper.KEY_UPLOADED, 1);
                        int res = messagesProviderHelper
                                .setPublic(c.getLong(c.getColumnIndex(MessagesProviderHelper.KEY_ID)), values);
                        if (res == 0) {
                            log.debug("Message with hash " + message_hash
                                    + " not found; this should never happen!");
                        }
                    }

                } catch (OAuthMessageSignerException e) {
                    log.debug("OAuthMessageSignerException: " + e);
                } catch (OAuthExpectationFailedException e) {
                    log.debug("OAuthExpectationFailedException: " + e);
                } catch (OAuthCommunicationException e) {
                    log.debug("OAuthCommunicationException: " + e);
                } catch (JSONException e) {
                    log.debug("JSON Error: " + e);
                } catch (IOException e) {
                    log.debug("IOException: " + e);
                }
            }
            c.moveToNext();
        }

        c.close();

    }

    setServiceState(STATE_SERVICE_WAIT);
}

From source file:de.ii.xtraplatform.ogc.api.wfs.client.WFSAdapter.java

private HttpResponse requestPOST(WFSOperation operation) throws ParserConfigurationException {

    URI url = findUrl(operation.getOperation(), WFS.METHOD.POST);

    HttpClient httpClient = url.getScheme().equals("https") ? this.untrustedSslHttpClient : this.httpClient;

    URIBuilder uri = new URIBuilder(url);

    String xml = operation.getPOSTXML(nsStore, versions);

    LOGGER.debug("{}\n{}", uri, xml);

    HttpPost httpPost;/*from w ww.  j  ava2  s . c o  m*/
    HttpResponse response = null;

    try {
        httpPost = new HttpPost(uri.build());

        for (String key : operation.getRequestHeaders().keySet()) {
            httpPost.setHeader(key, operation.getRequestHeaders().get(key));
        }

        // TODO: temporary basic auth hack
        if (useBasicAuth) {
            httpPost.addHeader("Authorization", "Basic " + basicAuthCredentials);
        }

        StringEntity xmlEntity = new StringEntity(xml, ContentType.create("text/plain", "UTF-8"));
        httpPost.setEntity(xmlEntity);

        response = httpClient.execute(httpPost, new BasicHttpContext());

        // check http status
        checkResponseStatus(response.getStatusLine().getStatusCode(), uri);

    } catch (SocketTimeoutException ex) {
        if (ignoreTimeouts) {
            LOGGER.warn("POST request timed out after %d ms, URL: {} \\nRequest: {}",
                    HttpConnectionParams.getConnectionTimeout(httpClient.getParams()), uri, xml);
        }
        response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "");
        response.setEntity(new StringEntity("", ContentType.TEXT_XML));
    } catch (IOException ex) {
        //LOGGER.error(ERROR_IN_POST_REQUEST_TO_URL_REQUEST, uri.toString(), xml, ex);
        //LOGGER.debug("Error requesting URL: {}", uri.toString());

        try {
            if (!isDefaultUrl(uri.build(), WFS.METHOD.POST)) {

                LOGGER.info("Removing URL: {}", uri);
                this.urls.remove(operation.getOperation().toString());

                LOGGER.info("Retry with default URL: {}", this.urls.get("default"));
                return requestPOST(operation);
            }
        } catch (URISyntaxException ex0) {
        }

        LOGGER.error("Failed requesting URL: '{}'", uri);
        throw new ReadError("Failed requesting URL: '{}'", uri);
    } catch (URISyntaxException ex) {
        LOGGER.error("Failed requesting URL: '{}'", uri);
        throw new ReadError("Failed requesting URL: '{}'", uri);
    } catch (ReadError ex) {
        LOGGER.error("Failed requesting URL: '{}'", uri);
        throw ex;
    }
    LOGGER.debug("WFS request submitted");
    return response;
}

From source file:com.FluksoViz.FluksoVizActivity.java

private boolean isFluksoRechableOverHTTP() {
    HttpClient httpclient = new DefaultHttpClient();
    HttpParams httpParams = httpclient.getParams();
    HttpConnectionParams.setConnectionTimeout(httpParams, 1000);
    HttpConnectionParams.setSoTimeout(httpParams, 1000);
    StatusLine statusLine = null;//from ww w. ja va 2  s . c  om
    HttpResponse response = null;
    try {
        response = httpclient.execute(new HttpGet("http://" + ip_addr + ":8080/"));
        statusLine = response.getStatusLine();
        if (statusLine != null) {
            if (statusLine.getStatusCode() == HttpStatus.SC_OK) {

                return true;
            } else {
                Toast.makeText(FluksoVizActivity.this, "bad IP?", Toast.LENGTH_LONG).show();
                response.getEntity().getContent().close();
                throw new IOException(statusLine.getReasonPhrase());

            }
        } else {
            throw new IOException();
        }
    } catch (ClientProtocolException e) {
        e.printStackTrace();
        Toast.makeText(FluksoVizActivity.this, R.string.exception + "\n" + e.toString(), Toast.LENGTH_LONG)
                .show();
        return false;

    } catch (SocketTimeoutException e) {
        Toast.makeText(FluksoVizActivity.this, R.string.flukso_ip_address_is_wrong + "\n" + e.toString(),
                Toast.LENGTH_LONG).show();
        e.printStackTrace();
        return false;
    } catch (IOException e) {
        Toast.makeText(FluksoVizActivity.this, R.string.exception + "\n" + e.toString(), Toast.LENGTH_LONG)
                .show();
        e.printStackTrace();
        return false;
    }

}

From source file:com.FluksoViz.FluksoVizActivity.java

private List<Number> getAPIdata(String IPA, String SENSOR_KEY) throws Exception, IOException {
    HttpClient httpclient = new DefaultHttpClient();
    HttpParams httpParams = httpclient.getParams();
    HttpConnectionParams.setConnectionTimeout(httpParams, 1000);
    HttpConnectionParams.setSoTimeout(httpParams, 1000);
    StatusLine statusLine = null;//from   ww w .  ja  v  a 2s  .c  om
    HttpResponse response = null;

    try {
        response = httpclient.execute(new HttpGet("http://" + IPA + ":8080/sensor/" + SENSOR_KEY
                + "?version=1.0&interval=minute&unit=watt&callback=realtime"));
        statusLine = response.getStatusLine();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
        // Napis3.setText(e.toString());
    } catch (SocketTimeoutException ste) {
        // Napis3.setText(ste.toString());
        ste.printStackTrace();
    } catch (IOException e) {
        // Napis3.setText(e.toString());
        e.printStackTrace();
    }

    if (statusLine != null) {
        if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            response.getEntity().writeTo(out);
            out.close();
            String responseString = out.toString().replace("realtime(", "").replace(")", "").replace("]", "")
                    .replace("[", "").replace("nan", "0").replace("\"", "");

            String[] responseArray = responseString.split(",");
            Number[] responseArrayNumber = new Number[responseArray.length];
            for (int numb = 0; numb < (responseArray.length) - 1; numb++) {
                responseArrayNumber[numb] = Integer.parseInt(responseArray[numb]);
            }
            series = Arrays.asList(responseArrayNumber);
            return series;
        } else {
            // Closes the connection.
            response.getEntity().getContent().close();
            throw new IOException(statusLine.getReasonPhrase());
        }
    } else {
        // response.getEntity().getContent().close();
        throw new IOException();
    }

}

From source file:de.ii.xtraplatform.ogc.api.wfs.client.WFSAdapter.java

private HttpResponse requestGET(WFSOperation operation) throws ParserConfigurationException {
    URI url = findUrl(operation.getOperation(), WFS.METHOD.GET);

    HttpClient httpClient = url.getScheme().equals("https") ? this.untrustedSslHttpClient : this.httpClient;

    URIBuilder uri = new URIBuilder(url);

    Map<String, String> params = operation.getGETParameters(nsStore, versions);

    for (Map.Entry<String, String> param : params.entrySet()) {
        uri.addParameter(param.getKey(), param.getValue());
    }//from   w ww.  j a  v  a2s . c om
    LOGGER.debug("GET Request {}: {}", operation, uri);

    boolean retried = false;
    HttpGet httpGet;
    HttpResponse response;

    try {

        // replace the + with %20
        String uristring = uri.build().toString();
        uristring = uristring.replaceAll("\\+", "%20");
        httpGet = new HttpGet(uristring);

        // TODO: temporary basic auth hack
        if (useBasicAuth) {
            httpGet.addHeader("Authorization", "Basic " + basicAuthCredentials);
        }

        response = httpClient.execute(httpGet, new BasicHttpContext());

        // check http status
        checkResponseStatus(response.getStatusLine().getStatusCode(), uri);

    } catch (SocketTimeoutException ex) {
        if (ignoreTimeouts) {
            LOGGER.warn("GET request timed out after %d ms, URL: {}",
                    HttpConnectionParams.getConnectionTimeout(httpClient.getParams()), uri);
        }
        response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "");
        response.setEntity(new StringEntity("", ContentType.TEXT_XML));
    } catch (IOException ex) {
        try {
            if (!isDefaultUrl(uri.build(), WFS.METHOD.GET)) {

                LOGGER.info("Removing URL: {}", uri);
                this.urls.remove(operation.getOperation().toString());

                LOGGER.info("Retry with default URL: {}", this.urls.get("default"));
                return requestGET(operation);
            }
        } catch (URISyntaxException ex0) {
        }
        LOGGER.error("Failed requesting URL: '{}'", uri);
        throw new ReadError("Failed requesting URL: '{}'", uri);
    } catch (URISyntaxException ex) {
        LOGGER.error("Failed requesting URL: '{}'", uri);
        throw new ReadError("Failed requesting URL: '{}'", uri);
    }
    LOGGER.debug("WFS request submitted");
    return response;
}

From source file:de.ii.xtraplatform.ogc.api.wfs.client.WFSAdapter.java

private HttpResponse requestGET(WfsOperation operation)
        throws ParserConfigurationException, TransformerException, IOException, SAXException {
    URI url = findUrl(operation.getOperation(), WFS.METHOD.GET);

    HttpClient httpClient = url.getScheme().equals("https") ? this.untrustedSslHttpClient : this.httpClient;

    URIBuilder uri = new URIBuilder(url);

    Map<String, String> params = operation.asKvp(new XMLDocumentFactory(nsStore), versions);

    for (Map.Entry<String, String> param : params.entrySet()) {
        uri.addParameter(param.getKey(), param.getValue());
    }//from   ww  w  .  ja va 2  s  .c  o m
    LOGGER.debug("GET Request {}: {}", operation, uri);

    boolean retried = false;
    HttpGet httpGet;
    HttpResponse response;

    try {

        // replace the + with %20
        String uristring = uri.build().toString();
        uristring = uristring.replaceAll("\\+", "%20");
        httpGet = new HttpGet(uristring);

        // TODO: temporary basic auth hack
        if (useBasicAuth) {
            httpGet.addHeader("Authorization", "Basic " + basicAuthCredentials);
        }

        response = httpClient.execute(httpGet, new BasicHttpContext());

        // check http status
        checkResponseStatus(response.getStatusLine().getStatusCode(), uri);

    } catch (SocketTimeoutException ex) {
        if (ignoreTimeouts) {
            LOGGER.warn("GET request timed out after %d ms, URL: {}",
                    HttpConnectionParams.getConnectionTimeout(httpClient.getParams()), uri);
        }
        response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "");
        response.setEntity(new StringEntity("", ContentType.TEXT_XML));
    } catch (IOException ex) {
        try {
            if (!isDefaultUrl(uri.build(), WFS.METHOD.GET)) {

                LOGGER.info("Removing URL: {}", uri);
                this.urls.remove(operation.getOperation().toString());

                LOGGER.info("Retry with default URL: {}", this.urls.get("default"));
                return requestGET(operation);
            }
        } catch (URISyntaxException ex0) {
        }
        LOGGER.error("Failed requesting URL: '{}'", uri);
        throw new ReadError("Failed requesting URL: '{}'", uri);
    } catch (URISyntaxException ex) {
        LOGGER.error("Failed requesting URL: '{}'", uri);
        throw new ReadError("Failed requesting URL: '{}'", uri);
    }
    LOGGER.debug("WFS request submitted");
    return response;
}

From source file:com.FluksoViz.FluksoVizActivity.java

private List<Number> getserwerAPIdata(String SENSOR_KEY, String SENSOR_TOKEN, String INTERVAL)
        throws Exception, IOException {
    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    schemeRegistry.register(new Scheme("https", new EasySSLSocketFactory(), 443));
    HttpParams params = new BasicHttpParams();
    params.setParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 30);
    params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, new ConnPerRouteBean(30));
    params.setParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false);

    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    ClientConnectionManager cm = new SingleClientConnManager(params, schemeRegistry);
    HttpClient httpclient2 = new DefaultHttpClient(cm, params);
    HttpParams httpParams = httpclient2.getParams();
    HttpConnectionParams.setConnectionTimeout(httpParams, 5000);
    HttpConnectionParams.setSoTimeout(httpParams, 5000);

    HttpResponse response = null;//from ww w . j a va  2s. c  o  m
    StatusLine statusLine2 = null;
    try {
        response = httpclient2.execute(new HttpGet("https://" + api_server_ip + "/sensor/" + SENSOR_KEY
                + "?version=1.0&token=" + SENSOR_TOKEN + "&interval=" + INTERVAL + "&unit=watt"));
        statusLine2 = response.getStatusLine();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
        throw new IOException("failed ClientProtocolException");
    } catch (SocketTimeoutException ste) {
        ste.printStackTrace();
        throw new IOException("failed SocketTimeoutExeption");
    } catch (IOException e) {
        e.printStackTrace();
        throw new IOException("IO failed API Server down?");
    }

    if (statusLine2.getStatusCode() == HttpStatus.SC_OK) {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        response.getEntity().writeTo(out);
        out.close();
        String responseString = out.toString().replace("]", "").replace("[", "").replace("nan", "0")
                .replace("\"", "");

        String[] responseArray = responseString.split(",");
        Number[] responseArrayNumber = new Number[responseArray.length];
        for (int numb = 0; numb < (responseArray.length) - 1; numb++) {
            responseArrayNumber[numb] = Integer.parseInt(responseArray[numb]);
        }

        List<Number> series = Arrays.asList(responseArrayNumber);

        return series;

    } else {
        // Closes the connection.
        response.getEntity().getContent().close();
        throw new IOException(statusLine2.getReasonPhrase());
    }

}

From source file:de.ii.xtraplatform.ogc.api.wfs.client.WFSAdapter.java

private HttpResponse requestPOST(WfsOperation operation)
        throws ParserConfigurationException, TransformerException, IOException, SAXException {

    URI url = findUrl(operation.getOperation(), WFS.METHOD.POST);

    HttpClient httpClient = url.getScheme().equals("https") ? this.untrustedSslHttpClient : this.httpClient;

    URIBuilder uri = new URIBuilder(url);

    String xml = operation.asXml(new XMLDocumentFactory(nsStore), versions).toString(false);

    LOGGER.debug("{}\n{}", uri, xml);

    HttpPost httpPost;//www. ja v a2s.  c  o m
    HttpResponse response = null;

    try {
        httpPost = new HttpPost(uri.build());

        /*for( String key : operation.getRequestHeaders().keySet()) {
        httpPost.setHeader(key, operation.getRequestHeaders().get(key));
        }*/

        // TODO: temporary basic auth hack
        if (useBasicAuth) {
            httpPost.addHeader("Authorization", "Basic " + basicAuthCredentials);
        }

        StringEntity xmlEntity = new StringEntity(xml, ContentType.create("text/plain", "UTF-8"));
        httpPost.setEntity(xmlEntity);

        response = httpClient.execute(httpPost, new BasicHttpContext());

        // check http status
        checkResponseStatus(response.getStatusLine().getStatusCode(), uri);

    } catch (SocketTimeoutException ex) {
        if (ignoreTimeouts) {
            LOGGER.warn("POST request timed out after %d ms, URL: {} \\nRequest: {}",
                    HttpConnectionParams.getConnectionTimeout(httpClient.getParams()), uri, xml);
        }
        response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "");
        response.setEntity(new StringEntity("", ContentType.TEXT_XML));
    } catch (IOException ex) {
        //LOGGER.error(ERROR_IN_POST_REQUEST_TO_URL_REQUEST, uri.toString(), xml, ex);
        //LOGGER.debug("Error requesting URL: {}", uri.toString());

        try {
            if (!isDefaultUrl(uri.build(), WFS.METHOD.POST)) {

                LOGGER.info("Removing URL: {}", uri);
                this.urls.remove(operation.getOperation().toString());

                LOGGER.info("Retry with default URL: {}", this.urls.get("default"));
                return requestPOST(operation);
            }
        } catch (URISyntaxException ex0) {
        }

        LOGGER.error("Failed requesting URL: '{}'", uri);
        throw new ReadError("Failed requesting URL: '{}'", uri);
    } catch (URISyntaxException ex) {
        LOGGER.error("Failed requesting URL: '{}'", uri);
        throw new ReadError("Failed requesting URL: '{}'", uri);
    } catch (ReadError ex) {
        LOGGER.error("Failed requesting URL: '{}'", uri);
        throw ex;
    }
    LOGGER.debug("WFS request submitted");
    return response;
}