.net rdf dblp 数据集查询 [英] .net rdf dblp dataset querying

查看:52
本文介绍了.net rdf dblp 数据集查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行以下代码以使用此代码片段查询 dblp 数据集时我正在使用这个端点 http://dblp.l3s.de/d2r/snorql在此处输入代码String st = "";字符串 qry = "";字符串uri_V;

when i run the following code to query the dblp dataset using this code snippet i am using this endpoint http://dblp.l3s.de/d2r/snorql enter code hereString st = ""; String qry = ""; String uri_V;

    uri_V = "http://dblp.l3s.de/d2r/sparql";



    // Modify if need......
    //String ns = "\""+TextBox1.Text.ToString()+"\"";
    // String qry = "SELECT DISTINCT ?name WHERE { ?person foaf:name ?name.FILTER regex(str(?name),"+ns+").}";
    if (radiosrch.SelectedIndex == 0)
    {
        qry = "SELECT ?title WHERE {?game <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:First-person_shooters> .?game foaf:name ?title .}ORDER by ?title";
    }
    else// if (radiosrch.SelectedIndex == 1) 
    {
        // qry= "query for publisher."
        qry = "SELECT DISTINCT ?Concept WHERE {[] a ?Concept} LIMIT 10";
    }


    //Common
    SparqlRemoteEndpoint endpoint = new SparqlRemoteEndpoint(new Uri(uri_V));
    SparqlResultSet results = endpoint.QueryWithResultSet(qry);
    foreach (SparqlResult result in results)
    {
        Console.WriteLine(result.ToString());
        st = st + result.ToString() + "\n";
    }
    TextBox3.Text = st.ToString();
}
catch (Exception ex)
{
    Label1.Visible = true;
    Label1.Text = ex.ToString();
}

我收到以下错误

VDS.RDF.Query.RdfQueryException:尝试进行 SPARQL 查询时发生 HTTP 错误,有关详细信息,请参阅内部异常 ---> System.Net.WebException:远程服务器返回错误:(400) 错误请求.在 System.Net.HttpWebRequest.GetResponse() 在 VDS.RDF.Query.SparqlRemoteEndpoint.ExecuteQuery(Uri target, String postData, String accept) 在 VDS.RDF.Query.SparqlRemoteEndpoint.QueryInternal(String sparqlQuery, String acceptHeader) 在 VDS.RDF.Query.SparqlRemoteEndpoint.QueryWithResultSet(ISparqlResultsHandler handler, String sparqlQuery) --- 内部异常堆栈跟踪结束--- 在 VDS.RDF.Query.SparqlRemoteEndpoint.QueryWithResultSet(ISparqlResultsHandler handler, String sparqlQuery) 在 VDS.RDF.Query.SparqlRemoteEndpoint.QueryWithResultSet(String sparqlQuery) at Index.ImageButton1_Click(Object sender, ImageClickEventArgs e) in d:\SPARQL\Index.aspx.cs:line 48

VDS.RDF.Query.RdfQueryException: A HTTP Error occurred while trying to make the SPARQL Query, see inner exception for details ---> System.Net.WebException: The remote server returned an error: (400) Bad Request. at System.Net.HttpWebRequest.GetResponse() at VDS.RDF.Query.SparqlRemoteEndpoint.ExecuteQuery(Uri target, String postData, String accept) at VDS.RDF.Query.SparqlRemoteEndpoint.QueryInternal(String sparqlQuery, String acceptHeader) at VDS.RDF.Query.SparqlRemoteEndpoint.QueryWithResultSet(ISparqlResultsHandler handler, String sparqlQuery) --- End of inner exception stack trace --- at VDS.RDF.Query.SparqlRemoteEndpoint.QueryWithResultSet(ISparqlResultsHandler handler, String sparqlQuery) at VDS.RDF.Query.SparqlRemoteEndpoint.QueryWithResultSet(String sparqlQuery) at Index.ImageButton1_Click(Object sender, ImageClickEventArgs e) in d:\SPARQL\Index.aspx.cs:line 48

请尽快帮我解决,请

推荐答案

请参阅 使用 dotNetRDF 调试 HTTP 通信

在您的请求之前设置以下内容:

Set the following prior to your request:

Options.HttpDebugging = true;

这将使 dotNetRDF 将有关 HTTP 请求和响应的调试信息打印到控制台,如果这还不够启发性,还可以启用以下内容:

This will then have dotNetRDF print debug information to the Console about the HTTP request and response, if this is not sufficiently enlightening also enable the following:

Options.HttpFullDebugging = false;

这会将完整的 HTTP 响应转储到控制台,以便您可以准确查看服务器发回的任何错误消息.

This will dump the full HTTP response to the Console so you can see exactly what error message if anything the server sent back.

然而打开后一个选项将导致后续代码失败,并出现不同的错误,因为预期的响应流不会耗尽,因此一旦这为您提供了足够的信息来调试您的问题,请不要忘记再次关闭它!

However turning on the latter option will cause subsequent code to fail with now different errors because the expected response stream will not be exhausted so once this has given you enough information to debug your problem don't forget to turn it off again!

这篇关于.net rdf dblp 数据集查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆