[Mulgara-general] Simple Rest Example Help

Paul Gearon gearon at ieee.org
Thu Feb 25 02:57:34 UTC 2010


Hi again,

On Wed, Feb 24, 2010 at 7:10 PM, Mark <javamark at gmail.com> wrote:
> The only part I am not sure on is how to create an initial store in a
> restful manner?

Have a look at:
  http://mulgara.org/trac/wiki/RESTGraphs

The PUT command creates a graph. The POST command will upload a graph.

> I did this using another web interface
> (http://localhost:8080/tutorial/ExecuteQuery)

That interface really isn't what you want.

Originally, the only web interface was that simple tutorial, that
showed a user how to create a graph, upload data, and then query it.
The idea was to lead users through the process. A couple of years ago
I completely re-implemented it, leaving it almost exactly as it was,
but with *way* less code.

Funnily enough, it proved to be such a useful interface that most
people used it rather than anything else. So I wrote another version
that didn't have the dropdown box with the tutorial commands. They
share 90% of their code, so they operate the same way. You can find
that interface at:
  http://localhost:8080/webui

But regardless of which one of these web apps you use, they are NOT
the REST interface. REST is instead found at:
  http://localhost:8080/sparql/
and also:
  http://localhost:8080/tql/

It's not completely REST, but it tries. Statements and graphs are
treated RESTfully, responding appropriately to PUT/GET/POST, etc. See:
  http://mulgara.org/trac/wiki/RESTGraphs
  http://mulgara.org/trac/wiki/RESTStatements

Queries are also on this interface, though they are not REST. For
details on this interface, see the SPARQL protocol document:
  http://www.w3.org/TR/rdf-sparql-protocol/

Extra information on queries and commands is given at:
  http://mulgara.org/trac/wiki/RESTQueries

> Graph URI: rmi://xpquad01.home/server1#test
> Query:       create <rmi://xpquad01.home/server1#test>;
>
> Note the URL http://localhost:8082/ were being proxied to
> http://localhost:8080 using tcptrace so i could see chat going on.

Ah, OK. That explains the 8082 I commented in on the previous email.

> I will write this up for others.

If you're going to do this, then I'd appreciate a writeup in the wiki.
(You just need to create an account). If the wiki is missing something
that you think it needs, or it was too hard to find stuff, then I'd
appreciate edits, or at least some pointers on what is needed to fix
it.

> I am a big fan of triple/quad stores, and
> last year challenged myself to ditch the RDBMS on a project and use a triple
> store instead.
>
> Since then I have been hooked.

Yeah, well, you're speaking to a biased crowd here.  :-)

> In my day job I work with AS400 / RPG developers where the
> database/schema/tables/columns have little or no semantic information, which
> is a big problem, since with 20 year old systems you want as much semantic
> info as possible since the original developers are long gone!
>
> Keep up the fantastic work.

NP. Let us know what you may be missing, or what you can't find
documentation for, and we'll try to keep up with you.

Regards,
Paul

> On 25 February 2010 00:00, Mark <javamark at gmail.com> wrote:
>>
>> "They will not be recognized if they appear in the request body. "
>>
>> Firefox poster encodes the parameters by default in the request body. So
>> instead I cut and pasted the generated/encoded parameter body onto the end
>> of the url and it worked
>>
>> PUT:
>>
>>
>> http://localhost:8082/sparql/?subject=http%3A%2F%2Fwww.w3.org%2F2000%2F08%2Fw3c-synd%2Fhome.rss&predicate=http%3A%2F%2Fpurl.org%2Frss%2F1.0%2Ffoo&object=bar&default-graph-uri=rmi%3A%2F%2Fxpquad01.home%2Fserver1%23test
>>
>> GET:
>>
>> http://localhost:8082/sparql/?query=SELECT%20%3Fa%20from%20%3Crmi%3A%2F%2Fxpquad01.home%2Fserver1%23test%3E%20WHERE%20%7B%20%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F08%2Fw3c-synd%2Fhome.rss%3E%20%20%3Chttp%3A%2F%2Fpurl.org%2Frss%2F1.0%2Ffoo%3E%20%3Fa%20%7D
>>
>> RESULT:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <sparql xmlns="http://www.w3.org/2005/sparql-results#">
>>   <head>
>>     <variable name="a"/>
>>   </head>
>>   <results>
>>     <result>
>>       <binding name="a">
>>         <uri>rmi://xpquad01.home/server1/bar</uri>
>>       </binding>
>>     </result>
>>   </results>
>> </sparql>
>>
>>
>>
>>
>> On 24 February 2010 23:39, Mark <javamark at gmail.com> wrote:
>>>
>>> Thanks Paul
>>>
>>> I get a little further is I use
>>>
>>> http://localhost:8080/sparql
>>>
>>> without the trailing slash.
>>>
>>> So far I have managed to to a 'GET'
>>>
>>> with a query parameter of SELECT ?a from
>>> <rmi://xpquad01.home/server1#sampledata> WHERE {
>>> <http://www.w3.org/2000/08/w3c-synd/home.rss>
>>> <http://purl.org/rss/1.0/title> ?a }
>>>
>>> on the data loaded by the tutorial.
>>>
>>> I have tried to do a PUT followed by a GET but no luck so far.
>>>
>>> I'm close.
>>>
>>> I will write this up, when I'm done.
>>>
>>> It's nearly midnight in the UK but I'm going to keep at it.
>>>
>>>
>>>
>>> On 24 February 2010 23:25, Paul Gearon <gearon at ieee.org> wrote:
>>>>
>>>> Hi Mark,
>>>>
>>>> Replying off list...
>>>>
>>>> At face value it looks like you've done the right thing. I'll have to
>>>> check it out for you.
>>>>
>>>> Unfortunately you've caught me at the time of night when I'm getting
>>>> dinner ready, and then have to get the kids into bed, so I can't get
>>>> to it straight away. I'll try for later tonight, or else first thing
>>>> in the morning.
>>>>
>>>> Regards,
>>>> Paul
>>>>
>>>> On Wed, Feb 24, 2010 at 5:47 PM, Mark <javamark at gmail.com> wrote:
>>>> > I am trying to try out a simple REST style example
>>>> >
>>>> > 1) Launch Mulgara with:
>>>> > java -jar mulgara-2.1.7.jar
>>>> >
>>>> > 2) Insert a statment using PUT  statement with the Firefox Poster
>>>> > plugin:
>>>> >
>>>> > URL: http://localhost:8080/sparql/
>>>> >
>>>> > Then I add four parameters:
>>>> > s http://name/mark
>>>> > p http://name/surname
>>>> > o java
>>>> > graph test:data
>>>> >
>>>> > the content type is set as: application/x-www-form-urlencoded
>>>> >
>>>> > therfore the parameter body is:
>>>> >
>>>> >
>>>> > s=http%3A%2F%2Fname%2Fmark&p=http%3A%2F%2Fname%2Fsurname&graph=test%3Adata&o=java
>>>> >
>>>> > when I submit this, I get:
>>>> >
>>>> > <html>
>>>> > <head>
>>>> > <meta http-equiv="Content-Type" content="text/html;
>>>> > charset=ISO-8859-1"/>
>>>> > <title>Error 400 No graph parameter defined.</title>
>>>> > </head>
>>>> > <body><h2>HTTP ERROR: 400</h2><pre>No graph parameter defined.</pre>
>>>> > <p>RequestURI=/sparql/</p><p><i><small><a
>>>> > href="http://jetty.mortbay.org/">Powered by
>>>> > Jetty://</a></small></i></p><br/>
>>>> >
>>>> > Any ideas?
>>>> >
>>>> > I would love to see a simple programatic restful client example using
>>>> > HttpClient for example?
>>>> >
>>>> > Thanks in advance
>>>> >
>>>> > _______________________________________________
>>>> > Mulgara-general mailing list
>>>> > Mulgara-general at mulgara.org
>>>> > http://mulgara.org/mailman/listinfo/mulgara-general
>>>> >
>>>> >
>>>
>>
>
>



More information about the Mulgara-general mailing list