http://revyu.com/sparql is sending back "Content-Type: text/html" but it's not HTML.

And when I tries "SELECT (1 AS ?Z) {}" it didn't return the right answers anyway (one row, one col, ?Z=1)

Best I can suggest is make the call with HttpOp.execHttpGet - your have to make the URL with thw "?query=" all correctly encoded (URLEncodedUtils.format(paramList, StandardCharsets.UTF_8) will help)

When to have it as an InputStream, use ResultSetFactor.fromXML

    Andy

On 25/11/2019 16:35, Hyrundo Publishing Association wrote:
Hello Sirs at Jena,

I get this stacktrace warning from Jena 3.12.0 on NetBeans IDE:

org.apache.jena.query.QueryException: Endpoint returned Content-Type: text/html 
which is not rcognized for SELECT queries

I’m trying to make the example query given at http://revyu.com/sparql/queryform 
<http://revyu.com/sparql/queryform>
but this time remotely against the revyu.com/sparql <http://revyu.com/sparql> 
endpoint, using the following class/main method:


import org.apache.jena.query.* ;
import org.apache.jena.sparql.engine.http.QueryEngineHTTP ;

public class SPARQLEndpointQuery
{
     static public void main(String...argv) {

         String queryStr =      "PREFIX rev: <http://purl.org/stuff/rev#>\n" +
                                        "PREFIX rdfs: 
<http://www.w3.org/2000/01/rdf-schema#> \n" +
                                        "\n" +
                                        "SELECT DISTINCT ?thing ?name ?review 
?createdOn \n" +
                                        "WHERE \n" +
                                        "{ \n" +
                                        "?thing rdfs:label ?name .\n" +
                                        "?thing rev:hasReview ?review .\n" +
                                        "?review rev:reviewer <people/tom> . 
\n" +
                                        "?review rev:createdOn ?createdOn \n" +
                                        "} \n" +
                                        "LIMIT 2 OFFSET 0";
Query query = QueryFactory.create(queryStr);

         // Remote execution.
         try ( QueryExecution qexec = 
QueryExecutionFactory.sparqlService("http://revyu.com/sparql";, query) ) {
             // Set the endpoint specific timeout:
             ((QueryEngineHTTP)qexec).addParam("timeout", "10000") ;

             // Execute:
             ResultSet rs = qexec.execSelect();
             ResultSetFormatter.out(System.out, rs, query);

         } catch (Exception e) {
             e.printStackTrace();
         }

     }
}


I don’t know why it doesn’t work… on a similar query against the DBpedia.com/sparql 
<http://dbpedia.com/sparql> endpoint everything worked fine.
Any hint? Thank you in advance

Best Regards
Hyrundo


Reply via email to