/** * @deprecated use {@link #SOSAdapter_OXFExtension(String)} instead * @param sosVersion * the SOS version. * @param requestBuilder * the custom request builder */ @Deprecated public SOSAdapter_OXFExtension(String sosVersion, ISOSRequestBuilder requestBuilder) { super(sosVersion, requestBuilder); setHttpClient(new SimpleHttpClient(5000, SOCKET_TIMEOUT)); }
public HttpResponse executeGet(String uri) throws HttpClientException { LOGGER.debug("executing GET method '{}'", uri); return executeMethod(new HttpGet(uri)); }
public HttpResponse executePost(String uri, String payloadToSend) throws HttpClientException { return executePost(uri, payloadToSend, ContentType.create("text/xml", Consts.UTF_8)); }
public HttpResponse executeGet(String baseUri, RequestParameters parameters) throws HttpClientException { try { URIBuilder uriBuilder = new URIBuilder(baseUri); for (String key : parameters.getParameterNames()) { if (parameters.isSingleValue(key)) { uriBuilder.addParameter(key, parameters.getSingleValue(key)); } else { Iterable<String> multipleValues = parameters.getAllValues(key); uriBuilder.addParameter(key, createCsvValue(multipleValues)); } } URI uri = uriBuilder.build(); LOGGER.debug("executing GET method '{}'", uri); return executeMethod(new HttpGet(uri)); } catch (URISyntaxException e) { throw new HttpClientException("Invalid base URI: " + baseUri, e); } }
/** * Creates an instance with the given timeouts. * * @param connectionTimeout * the connection timeout in milliseconds. * @param socketTimeout * the socket timout in milliseconds. */ public SimpleHttpClient(int connectionTimeout, int socketTimeout) { ClientConnectionManager cm = getConnectionManager(); this.httpclient = (cm == null) ? new DefaultHttpClient() : new DefaultHttpClient(cm); this.httpclient.getParams().setParameter(CONNECTION_TIMEOUT, connectionTimeout); this.httpclient.getParams().setParameter(SO_TIMEOUT, socketTimeout); }
/** * Allows to create an SOSAdapter with custom (non-default) instance of {@link ISOSRequestBuilder}.<br> * <br> * By default the created instance will use a {@link SimpleHttpClient} for service communication. If * further features are needed the {@link SimpleHttpClient} can be decorated with further configuration * setups like a {@link GzipEnabledHttpClient} or a {@link ProxyAwareHttpClient}. * * @param serviceVersion * the schema version for which this adapter instance shall be initialized. * @param requestBuilder * a custom request builder implementation, if <code>null</code> a default builder will be used * (according to the given version). * @see ISOSRequestBuilder */ public SOSAdapter(final String serviceVersion, final ISOSRequestBuilder requestBuilder) { httpClient = new SimpleHttpClient(); this.serviceVersion = serviceVersion; if (requestBuilder == null) { this.requestBuilder = SOSRequestBuilderFactory.generateRequestBuilder(serviceVersion); } else { this.requestBuilder = requestBuilder; } }
public HttpResponse executePost(String uri, String payloadToSend, ContentType contentType) throws HttpClientException { StringEntity requestEntity = new StringEntity(payloadToSend, contentType); LOGGER.trace("payload to send: {}", payloadToSend); return executePost(uri, requestEntity); }
public HttpResponse executePost(String uri, HttpEntity payloadToSend) throws HttpClientException { LOGGER.debug("executing POST method to '{}'.", uri); HttpPost post = new HttpPost(uri); post.setEntity(payloadToSend); return executeMethod(post); }
/** * Creates an adapter to connect SOS with SOAP binding. <br> * <br> * Per default the Adapter uses {@link SoapSOSRequestBuilder_200} to build its request. Override via * {@link #setRequestBuilder(ISOSRequestBuilder)}. * * @param sosVersion * the SOS version */ public SOSwithSoapAdapter(String sosVersion) { super(sosVersion, new SimpleHttpClient(5000, SOCKET_TIMEOUT)); setRequestBuilder(new SoapSOSRequestBuilder_200()); }
public HttpResponse executePost(String uri, XmlObject payloadToSend) throws HttpClientException { return executePost(uri, payloadToSend.xmlText(), ContentType.create("text/xml", Consts.UTF_8)); }
/** * @param sosVersion the SOS version the adapter shall connect to. */ public SOSAdapter_OXFExtension(String sosVersion) { super(sosVersion, new SimpleHttpClient(5000, SOCKET_TIMEOUT)); setRequestBuilder(SosRequestBuilderFactory.createRequestBuilder(sosVersion)); }
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); } }
/** * Creates an adapter to connect SOS with SOAP binding. <br> * <br> * We use the overloaded constructor {@link SOSAdapter#SOSAdapter(String, ISOSRequestBuilder)} just to * satisfy reflection loading. Actually, there is <b>no parameter needed</b> for * <code>requestBuilder</code> and is not looked at at all (so it can be <code>null</code>). The * constructor creates its own {@link SOSRequestBuilderGET_200} instance internally by itself. <br> * * @deprecated use {@link #SOSwithSoapAdapter(String)} instead * @param sosVersion * the SOS version * @param requestBuilder * only for satisfying reflection loading and can be <code>null</code>. */ public SOSwithSoapAdapter(String sosVersion, ISOSRequestBuilder requestBuilder) { super(sosVersion, new SoapSOSRequestBuilder_200()); setHttpClient(new SimpleHttpClient(5000, SOCKET_TIMEOUT)); LOGGER.warn("This is a deprecated constructor and will be removed soon w/o notice."); }
OXFException { if (connectionTimeout > 0 && readTimeout < 1) { httpClient = new GzipEnabledHttpClient(new ProxyAwareHttpClient(new SimpleHttpClient(connectionTimeout))); httpClient = new GzipEnabledHttpClient(new ProxyAwareHttpClient(new SimpleHttpClient(connectionTimeout, readTimeout)));
HttpClient httpClient = new ProxyAwareHttpClient(new SimpleHttpClient()); HttpResponse httpResponse = httpClient.executePost(this.sosUrl.trim(), getDataAvailability, ContentType.TEXT_XML); HttpEntity responseEntity = httpResponse.getEntity();
SoapSOSRequestBuilder_200 builder = (SoapSOSRequestBuilder_200) getRequestBuilder(); String request = builder.buildGetDataAvailabilityRequest(parameters); HttpClient httpClient = new ProxyAwareHttpClient(new SimpleHttpClient()); String url = operation.getDcps()[0].getHTTPGetRequestMethods().get(0).getOnlineResource().getHref(); HttpResponse httpResponse = httpClient.executePost(url, request, ContentType.TEXT_XML);
HttpClient httpClient = new ProxyAwareHttpClient(new SimpleHttpClient()); HttpResponse httpResponse = httpClient.executePost(uri, request); HttpEntity responseEntity = httpResponse.getEntity();