我有一个问题Federated Query
。它仅用作我的项目的示例。
我通过 Wikidata 中的 DBpedia SPARQL Endpoint 检索所有 Wikimedia 类别,但这不是问题,因为下面的查询在 Wikidata 中有效。
但是当我想在 Apache Jena Query 上运行它时,它会抛出一个HttpException 404
. 为什么?
询问:
prefix bd: <http://www.bigdata.com/rdf#>
prefix dbc: <http://dbpedia.org/resource/Category:>
prefix dct: <http://purl.org/dc/terms/>
prefix wikibase: <http://wikiba.se/ontology#>
SELECT ?objectLabel WHERE {
SERVICE <http://dbpedia.org/sparql> {
?subject dct:subject dbc:Countries_in_Asia ; owl:sameAs ?object
FILTER (STRSTARTS(STR(?object), "http://www.wikidata.org"))
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
Java 代码:
public static ResultSet executeQuery(String queryString, String service) {
Query query = QueryFactory.create(queryString);
QueryEngineHTTP queryEngine = QueryExecutionFactory.createServiceRequest(service, query);
ResultSet resultSet = queryEngine.execSelect();
return resultSet;
}
服务 = 我使用的 SPARQL 端点服务https://query.wikidata.org/sparql
Apache Jena 中的异常跟踪:
HttpException: 404
at org.apache.jena.sparql.engine.http.HttpQuery.execGet(HttpQuery.java:325)
at org.apache.jena.sparql.engine.http.HttpQuery.exec(HttpQuery.java:282)
at org.apache.jena.sparql.engine.http.QueryEngineHTTP.execResultSetInner(QueryEngineHTTP.java:342)
at org.apache.jena.sparql.engine.http.QueryEngineHTTP.execSelect(QueryEngineHTTP.java:334)