public partial class Index : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
try
{
String st = "";
String qry = "";
String uri_V;
String dguri_V;
// uri_V = "http://dbpedia.org/sparql";
// dguri_V = "http://dbpedia.org";
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+").}";
qry = "SELECT ?x WHERE { ?x dcterms:issued ?year} LIMIT 20";
// qry = "SELECT ?name WHERE { ?x dcterms:issued ?year. FILTER (?year>2011). ?x dc:creator ?author. ?author foaf:name ?name. } LIMIT 20";
/* if (radiosrch.SelectedIndex == 0)
{
qry = "SELECT DISTINCT ?Concept WHERE {[] a ?Concept} LIMIT 5";
}
else// if (radiosrch.SelectedIndex == 1)
{
// qry= "query for publisher."
qry = "SELECT DISTINCT ?Concept WHERE {[] a ?Concept} LIMIT 5";
}
*/
//Common
SparqlRemoteEndpoint endpoint = new SparqlRemoteEndpoint(new Uri(uri_V));//, dguri_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: 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 53
しかし、http://dblp.l3s.de/d2r/snorqlエンドポイントでこのクエリを実行すると、絶対にエラーは発生しません。PLZ助けてください!!