.net rdf dblp dataset querying

爱⌒轻易说出口 提交于 2019-12-12 06:30:34

问题


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();
}

I get the following error

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

Plz help me resolve ASAP,plz


回答1:


See the documentation on Debugging HTTP Communications with dotNetRDF

Set the following prior to your request:

Options.HttpDebugging = true;

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;

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!



来源:https://stackoverflow.com/questions/15800269/net-rdf-dblp-dataset-querying

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!