我试图使用 FedX 创建一个远程联邦。下面是我的代码。第一个三重模式在"语义网狗粮"SPARQL 端点上运行时给出结果,而第二个三重模式在 DBPedia SPARQL 端点上运行。任何人都可以解释一下代码有什么问题吗?我尝试了查询并收到 406 错误。我在没有任何代理的情况下连接到互联网。
package Query;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import org.openrdf.query.QueryLanguage;
import org.openrdf.query.TupleQuery;
import org.openrdf.query.TupleQueryResult;
import org.openrdf.repository.Repository;
import com.fluidops.fedx.Config;
import com.fluidops.fedx.FedXFactory;
import com.fluidops.fedx.FederationManager;
import java.util.Arrays;
public class QueryFedX {
public static void main(String[] args) {
try
{
Config.initialize();
Repository repo = FedXFactory.initializeSparqlFederation(Arrays.asList(
"http://dbpedia.org/sparql",
"http://data.semanticweb.org/sparql"
));
String q = "SELECT ?y ?z WHERE { <http://data.semanticweb.org/organization/university-of-oxford> <http://www.w3.org/2000/01/rdf-schema#label> ?z . ?y <http://www.wikidata.org/entity/P373> ?z .}";
TupleQuery query = repo.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, q);
TupleQueryResult res = query.evaluate();
while (res.hasNext()) {
System.out.println(res.next());
}
FederationManager.getInstance().shutDown();
System.out.println("Done.");
System.exit(0);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
您遇到了我们在 [1] 和 [2] 中已经讨论过的相同问题:最近,公共 DBpedia 端点更改了权限,不再允许 SPARQL ASK 查询。由于FedX依赖于SPARQL ASK查询进行源选择,因此您会看到HTTP错误。
在 FedX 3.1 中,我们已经解决了这个问题(参见 [2]),并可以选择使用 SELECT 查询来确定来源。您是否已经在使用 FedX 3.1?有关详细信息,请查看捆绑的文档和引用的线程。另外,如果这解决了问题,请告诉我们。
引用
[1] https://groups.google.com/forum/#!topic/iwb-discussion/Fb6SwQRWdv4
[2] https://groups.google.com/forum/#!topic/iwb-discussion/aIHtzvNk4v0