public HttpResponse executeGet(String uri) throws HttpClientException { return httpclient.executeGet(uri); }
public HttpResponse executeGet(String baseUri, RequestParameters parameters) throws HttpClientException { return httpclient.executeGet(baseUri, parameters); }
public static void main(final String[] args) { try { final HttpClient client = new SimpleHttpClient(); final String request = "http://sensorweb.demo.52north.org/52nSOSv3_200/sos?REQUEST=GetCapabilities&SERVICE=SOS"; final HttpResponse response = client.executeGet(request); final HttpEntity responseEntity = response.getEntity(); final InputStream responseStream = responseEntity.getContent(); new SOSCapabilitiesMapper_200().mapCapabilities(CapabilitiesDocument.Factory.parse(responseStream)); } catch (final HttpClientException | IOException | XmlException | OXFException e) { LOGGER.error("Exception thrown: {}",e.getMessage(),e); } }
@Override public void sendViaGet(String serviceUrl, HttpClient httpClient) { try { HttpResponse response = httpClient.executeGet(serviceUrl, parameters); int statusCode = response.getStatusLine().getStatusCode(); InputStream responseStream = getResponseStreamFrom(response); responseHandler.onSuccess(responseStream, statusCode); } catch (HttpClientException e) { LOGGER.error("Sending GetCapabilities failed.", e); responseHandler.onFailure(e.getMessage()); } catch (IOException e) { LOGGER.error("Could not create response stream.", e); responseHandler.onFailure(e.getMessage()); } }
@Override public OperationResult doOperation(Operation operation, ParameterContainer parameters) throws ExceptionReport, OXFException { try { String httpGETRequest = createHttpGETRequest(operation, parameters); LOGGER.debug("Send GET request '{}'", httpGETRequest); HttpResponse httpResponse = httpClient.executeGet(httpGETRequest); HttpEntity responseEntity = httpResponse.getEntity(); String responseString = inputStreamToString(responseEntity.getContent()); XmlObject response = parseToXmlObject(responseString); OperationResult result = new OperationResult(response.newInputStream(), parameters, httpGETRequest); checkForExceptionReport(result, response); return result; } catch (IOException e) { throw new OXFException("Error while reading operation result.", e); } catch (XmlException e) { throw new OXFException("Could not parse response to XML.", e); } catch (HttpClientException e) { throw new OXFException("Could not send request.", e); } }
HttpResponse httpResponse = null; if (isHttpGet) { httpResponse = myHttpClient.executeGet(uri.trim()); } else { httpResponse = myHttpClient.executePost(uri.trim(), request, mimetype);