Spurred by my belief in the Construct Infrastructure I took my official t-shirt with me in my backpack. In my role as Construct evangalist I’ll document the far reaching effects we’re having through a few photos. First is Rio de Janero in Brazil:
Provided my bag doesn’t get stolen there will be more to follow.
Part 2
And here it is. On Monday (8/9) I deployed Construct 0.8a to Machu Picchu in Peru. The Inkas love it. When I left the Inka chief was in deep discussion about named graph support and php-based web mashups over a hot cup of coca tea:
In part 1 of this post I described the new HTTP Port in Construct. In this part of the post I’ll explain how to write a web form and style the return values.
SPARQL Query
You can send a query to Construct with GET or POST. Here is how we do it in HTML with GET:
<textareaname=“q”cols=“64″rows=“10″>SELECT ?subject ?predicate ?object WHERE {?subject ?predicate ?object}</textarea><br/>URL of XSLT to apply (optional):<br/><inputtype=“text”name=“xsl”size=“56″value=“http://www.construct-infrastructure.org/stylesheets/default.xsl type=”submit” value=”Submit Query“>
</form>
the only thing the HTTP Port wants is the query field to be called either “q” or “query”. The returned XML will be sent back to your browser. Something like this:
To make the results look neater you can apply and XSL stylesheet. Send the URL for the XSL stylesheet as a field “xsl” in the form. This stylesheet must be web accessible. We’ve made a default example stylesheet you can use to get started.
Inserting N-3 RDF Data
You can insert new data into Construct using a form like this (we’re using POST this time for variety but GET works too):
<textareaname=“i”cols=“64″rows=“10″><http://www.pervasive-ontologies.org/ontologies/sensors/bluetooth#reading00:19:63:96:56:01@00:80:98:94:AE:4B@1201631502><http://www.pervasive-ontologies.org/ontologies/sensors/bluetooth#spotted>“00:19:63:96:56:01″.</textarea><br/>Expiry time for data (optional):<br/><inputtype=“text”name=“expiry”size=“15″value=“20000″><br/><inputtype=“submit”value=“Submit Data”>
</form>
in this form you send the data to be inserted as a field “i” or “insert”.
The returned data from an insert is an XML document with a status code and any messages given back from Construct. It looks something like this:
<response>
<status>OK</status>
<description>The data <http://www.pervasive-ontologies.org/ontologies/sensors/bluetooth#reading00:19:63:96:56:01@00:80:98:94:AE:4B@1201631502><http://www.pervasive-ontologies.org/ontologies/sensors/bluetooth#spotted>“00:19:63:96:56:01″. with given expiry 20000 was passed to the Construct data store without error.
</description>
</response>
Well, that is about it. You can make calls to Construct over HTTP from browsers or web applications using the HTTP Port. Have fun.
The latest release of Construct has the new HTTP Port enabled by default. The HTTP Port has similar functionality to the data port — you can use it to insert and query for data in Construct. The difference is that the data port works over raw TCP sockets, whereas the HTTP Port works over HTTP.
Now we can query Construct through a web browser and web apps… neat, huh?
these lines activate the HTTP Port on port 8888. When you have Construct running, open your web browser and go to http://localhost:8888/ and you should a simple set of forms for querying and inserting data using HTTP GET and HTTP POST. It looks something like this:
From this page you can send RDF data in N-3 format or SPARQL queries to Construct. Try clicking on one of the buttons to test it out.
This is the end of Part 1 on the HTTP Port. Part 2 of this post will explain how to build your own web forms and use of XSL stylesheets for your results.