// Execute the method.
int statusCode = client.executeMethod(method);
if (statusCode != HttpStatus.SC_OK) {
LOG.error("SparqlQuery failed: " + method.getStatusLine());
throw new SparqlExecutionException(String.format("%s (%s). %s",
method.getStatusLine(),
method.getURI(),
method.getResponseBodyAsString()));
}
// Read the response body.
byte[] responseBody = method.getResponseBody();
// Deal with the response.
// Use caution: ensure correct character encoding and is not binary data
response = new String(responseBody);
} catch (HttpException e) {
System.err.println("Fatal protocol violation: " + e.getMessage());
throw new SparqlExecutionException(e);
} catch (IOException e) {
System.err.println("Fatal transport error: " + e.getMessage());
throw new SparqlExecutionException(e);
} finally {
// Release the connection.
method.releaseConnection();
}
return response;