Implements a SPARQL Protocol server for ASP.NET.
This class implements the System.Web.IHttpHandler interface to provide a SPARQL Protocol query server over HTTP.
To activate the SPARQL server in your ASP.NET site, place the SemWeb.dll, SemWeb.Sparql.dll, and sparql-core.dll assemblies in the bin directory of your ASP.NET application. Then add the following to your web.config file. Note that you must specify a spec string to a data source to serve, as described in SemWeb.Store.CreateForInput(string).
Example <configuration> <configSections> <section name="sparqlSources" type="System.Configuration.NameValueSectionHandler"/> </configSections> <system.web> <httpHandlers> <!-- This line associates the SPARQL Protocol implementation with a path on your website. With this, you get a SPARQL server at http://yourdomain.com/sparql. --> <add verb="*" path="sparql" type="SemWeb.Query.SparqlProtocolServerHandler, SemWeb.Sparql" /> </httpHandlers> </system.web> <sparqlSources> <!-- This line configures the data source associated with each SPARQL server added above. This sets the server to query the RDF/XML file at the given path. You can use any spec string described in SemWeb.Store.CreateForInput(). --> <add key="/sparql" value="xml:/home/user/datafile.rdf"/> </sparqlSources> </configuration>Precede the data source specification string with "rdfs+" to wrap the data source with the SemWeb.Inference.RDFS reasoning engine. And precede that with "noreuse," to create a new instance of the data source on each request, which is good for SQL-backed stores to allow for concurrent queries, but bad for file-backed stores which would be read from disk on each request. For instance:
Example <add key="/sparql" value="noreuse,rdfs+mysql:rdftable:Database=databasename;Server=localhost;User Id=username"/>Using Mono's XSP light-weight web server, you can create a standalone SPARQL Protocol server by:
- Creating a new directory for your server.
- Creating a bin directory within it, and placing the files mentioned above into the directory.
- Creating a web.config file in the directory using the template above.
- Running "xsp" or "xsp2" from within the directory. Use "xsp" if you have include the .NET 1.1 SemWeb binary DLLs, otherwise "xsp2".
To run the SPARQL protocol server under Apache with mod_mono, you just need to place the web.config file in a working ASP.NET application and instruct Apache to use ASP.NET to handle the path to the endpoint Here's a minimal Apache configuration:
Example MonoAutoApplication disabled MonoServerPath /usr/local/bin/mod-mono-server2 # if using the .NET 2.0 SemWeb DLLs only MonoApplications "/:/var/www" <Location /sparql> SetHandler mono </Location>To use Apache and mod_aspdotnet on Windows, use this Apache configuration instead:
Example AspNetMount / "C:/webserver/doc_root" <Location /sparql> SetHandler asp.net AspNet Virtual </Location>You may want to add this index.html file to create a form to experiment with SPARQL queries:
Example <html> <body> <form action="/sparql" method="get"> <input type="hidden" name="outputMimeType" value="text/xml"/> <textarea name="query" rows="10" cols="80"> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX pol: <tag:govshare.info,2005:rdf/politico/> SELECT * WHERE { ?s rdf:type pol:Politician . ?s foaf:gender "male" . ?s foaf:name ?name . } LIMIT 10 </textarea> <p><input type="submit"/></p> </form> </body> </html>
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0
See Also: Inherited members from object.
⊟ Public Constructors
Creates a new SPARQL Protocol implementation class. ⊟ Public Fields
MaximumLimit int . The maximum number of bindings to return for any query. ⊟ Public Methods
ProcessRequest (System.Web.HttpContext) Processes an HTTP request from the ASP.NET subsystem.⊟ Protected Methods
CreateQuery (string) : Query Constructs a Query object for a SPARQL query.GetDataSource (out bool) : SemWeb.SelectableSource Gets the data source to query.RunQuery (Query, SemWeb.SelectableSource, System.IO.TextWriter) Runs a query.⊟ Explicitly Implemented Interface Members
[read-only] System.Web.IHttpHandler.IsReusable bool . Documentation for this section has not yet been entered.
⊟ SparqlProtocolServerHandler Constructor
Creates a new SPARQL Protocol implementation class.
public SparqlProtocolServerHandler ()⊟ Remarks
This class does not listen on an HTTP port by itself. It is meant to be embedded in an ASP.NET site.⊟ Requirements
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0
⊟ CreateQuery Method
Constructs a Query object for a SPARQL query.
⊟ Parameters
- query
- The SPARQL query as a string.
⊟ Returns
A Query object.⊟ Remarks
The default implementation returns a new SPARQL query object based on the query. Override in subclasses to create a query in a different way, or to set limits on the query.⊟ Requirements
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0
⊟ GetDataSource Method
Gets the data source to query.
protected virtual SemWeb.SelectableSource GetDataSource (out bool closeAfterQuery)⊟ Parameters
- closeAfterQuery
- Set to true to indicate that the data source should be closed/disposed after the query is complete.
⊟ Returns
A data source to query.⊟ Remarks
None.⊟ Requirements
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0
⊟ MaximumLimit Field
The maximum number of bindings to return for any query.
public int MaximumLimit⊟ Remarks
Set to -1, the default, to have no limit.⊟ Requirements
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0
⊟ ProcessRequest Method
Processes an HTTP request from the ASP.NET subsystem.
public virtual void ProcessRequest (System.Web.HttpContext context)⊟ Parameters
- context
- The request context.
⊟ Remarks
This method is not meant to be called from user code.⊟ Requirements
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0
⊟ RunQuery Method
Runs a query.
protected virtual void RunQuery (Query query, SemWeb.SelectableSource source, System.IO.TextWriter output)⊟ Parameters
- query
- The query to run.
- source
- The data source to query against.
- output
- The output stream.
⊟ Remarks
The default implementation runs the query on the data source and outputs the results in the SPARQL XML Results specification format. Override in subclasses to output the results in a different way, to run the query differently, or to set limits on the query or output.⊟ Requirements
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0
⊟ System.Web.IHttpHandler.IsReusable Property
Documentation for this section has not yet been entered.
bool System.Web.IHttpHandler.IsReusable { get; }⊟ Value
Documentation for this section has not yet been entered.⊟ Remarks
Documentation for this section has not yet been entered.⊟ Requirements
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0