Retriving RDF serialization of a NamedGraph from parametrized GET

6 views
Skip to first unread message

Busa

unread,
Jun 10, 2009, 11:43:39 AM6/10/09
to OpenAnzo
Hi all the OpenAnzo.
I'm really new to OpenAnzo and I would try to use it as a Semantic
Service Bus for my architecture.

At the moment I'm particularly interecsted in retriving the RDF
serialization file (as I can do in Comand Line Interface using "get -o
RDFXML -f myfile.rdf ...") of a namedgraph direclty from an URL (i.e
usinig a servlet already given).

That's because I'm using another application (SWED Portal) that do an
harvasting of a remote RDF file so...having a simple URL like this:
http://localhost:8080/rdf_service?namedGraph=....?output="RDFXML"

I could immediatly and easly integrate Anzo with my harvasting
application without writing any custom code.

Is it possible? Some other idea?

Let me know please.

Thankyou

Busa.

Jordi Albornoz Mulligan

unread,
Jun 14, 2009, 8:06:27 PM6/14/09
to open...@googlegroups.com
Hello Busa,

Indeed that would be very useful. We've been kicking around mechanisms
like that and it's likely that one will appear in Open Anzo soon.

There is one thing you can try until then. It's not the most elegant
solution but it might help you. You can use the SPARQL protocol to
retrieve the contents of a specific graph via HTTP.

What we do is use this simple query:
CONSTRUCT { ?s ?p ?o } { ?s ?p ?o }
which just returns all triples in the SPARQL default-graph.
Then we can make a SPARQL query via HTTP as defined in the SPARQL protocol:
http://www.w3.org/TR/rdf-sparql-protocol/
and we make the default-graph-uri be the graph we want.

For example, to retrieve a graph called http://example.com/myGraph you
could do:
http://localhost:8080/sparql/?query=CONSTRUCT%20%7B%20%3Fs%20%3Fp%20%3Fo%20%7D%20%7B%20%3Fs%20%3Fp%20%3Fo%20%7D&default-graph-uri=http%3A%2F%2Fexample.com%2FmyGraph

Try it with curl:
curl -u sysadmin:123 -H "Accept: application/rdf+xml"
"http://localhost:8080/sparql/?query=CONSTRUCT%20%7B%20%3Fs%20%3Fp%20%3Fo%20%7D%20%7B%20%3Fs%20%3Fp%20%3Fo%20%7D&default-graph-uri=http%3A%2F%2Fexample.com%2FmyGraph"

Not the prettiest but it works.
Hope that helps.
--
Jordi Albornoz Mulligan
Founding Engineer - Cambridge Semantics
jo...@cambridgesemantics.com
(617) 401-7321

Matteo

unread,
Jun 15, 2009, 8:56:05 AM6/15/09
to OpenAnzo
Oh thanx. This is a good suggestion.
I'll try and and I'll tell you if it works.

Thanx again,
Busa.

On Jun 15, 2:06 am, Jordi Albornoz Mulligan
<jo...@cambridgesemantics.com> wrote:
> Hello Busa,
>
> Indeed that would be very useful. We've been kicking around mechanisms
> like that and it's likely that one will appear in Open Anzo soon.
>
> There is one thing you can try until then. It's not the most elegant
> solution but it might help you. You can use the SPARQL protocol to
> retrieve the contents of a specific graph via HTTP.
>
> What we do is use this simple query:
> CONSTRUCT { ?s ?p ?o } { ?s ?p ?o }
> which just returns all triples in the SPARQL default-graph.
> Then we can make a SPARQL query via HTTP as defined in the SPARQL protocol:http://www.w3.org/TR/rdf-sparql-protocol/
> and we make the default-graph-uri be the graph we want.
>
> For example, to retrieve a graph calledhttp://example.com/myGraphyou
> could do:http://localhost:8080/sparql/?query=CONSTRUCT%20%7B%20%3Fs%20%3Fp%20%...
>
> Try it with curl:
> curl -u sysadmin:123 -H "Accept: application/rdf+xml"
> "http://localhost:8080/sparql/?query=CONSTRUCT%20%7B%20%3Fs%20%3Fp%20%..."

Matteo

unread,
Jun 15, 2009, 12:30:55 PM6/15/09
to OpenAnzo
Hi.
I tried you solution but nothing back from the sparql servlet.

In my case I have imported an RDF named http://imolinfo.it/undefined

and I made this request:
http://localhost:8282/sparql/?query=CONSTRUCT%20%7B%20%3Fs%20%3Fp%20%3Fo%20%7D%20%7B%20%3Fs%20%3Fp%20%3Fo%20%7D&default-graph-uri=http%3A%2F%2Fimolinfo.it%2Fundefined
but I get an empty response. No error, only an empty reply.

But if I check on the command interface with "anzo get -o RDFXML
http://imolinfo.it/undefined" I get all the RDF wanted.

Where I'm wrong?
Did you tested this kind of request to the sparql server?

Thanx,
Busa.


On Jun 15, 2:06 am, Jordi Albornoz Mulligan
<jo...@cambridgesemantics.com> wrote:
> Hello Busa,
>
> Indeed that would be very useful. We've been kicking around mechanisms
> like that and it's likely that one will appear in Open Anzo soon.
>
> There is one thing you can try until then. It's not the most elegant
> solution but it might help you. You can use the SPARQL protocol to
> retrieve the contents of a specific graph via HTTP.
>
> What we do is use this simple query:
> CONSTRUCT { ?s ?p ?o } { ?s ?p ?o }
> which just returns all triples in the SPARQL default-graph.
> Then we can make a SPARQL query via HTTP as defined in the SPARQL protocol:http://www.w3.org/TR/rdf-sparql-protocol/
> and we make the default-graph-uri be the graph we want.
>
> For example, to retrieve a graph calledhttp://example.com/myGraphyou
> could do:http://localhost:8080/sparql/?query=CONSTRUCT%20%7B%20%3Fs%20%3Fp%20%...
>
> Try it with curl:
> curl -u sysadmin:123 -H "Accept: application/rdf+xml"
> "http://localhost:8080/sparql/?query=CONSTRUCT%20%7B%20%3Fs%20%3Fp%20%..."

Jordi Albornoz Mulligan

unread,
Jun 15, 2009, 12:42:58 PM6/15/09
to open...@googlegroups.com
Matteo wrote:
> Hi.
> I tried you solution but nothing back from the sparql servlet.
>
> In my case I have imported an RDF named http://imolinfo.it/undefined
>
> and I made this request:
> http://localhost:8282/sparql/?query=CONSTRUCT%20%7B%20%3Fs%20%3Fp%20%3Fo%20%7D%20%7B%20%3Fs%20%3Fp%20%3Fo%20%7D&default-graph-uri=http%3A%2F%2Fimolinfo.it%2Fundefined
> but I get an empty response. No error, only an empty reply.
>
> But if I check on the command interface with "anzo get -o RDFXML
> http://imolinfo.it/undefined" I get all the RDF wanted.
>
> Where I'm wrong?
> Did you tested this kind of request to the sparql server?

Hello Busa,

Yes, I did test it and can get back data.
One gotcha that I noticed is that you need a specific "Accept" header in
the request. If you send something general like
Accept: */*
then it won't work right now.
Try something more specific like: "Accept: application/rdf+xml"

In the curl example command from the previous email, I set the header so
that you get the proper results.
For example:


curl -u sysadmin:123 -H "Accept: application/rdf+xml"
"http://localhost:8080/sparql/?query=CONSTRUCT%20%7B%20%3Fs%20%3Fp%20%..."

I filed a ticket related to this issue:
http://www.openanzo.org/projects/openanzo/ticket/656

Matteo

unread,
Jun 16, 2009, 3:32:56 AM6/16/09
to OpenAnzo
Ok.
I did all test using a browser.
I'll try using curl or something like that as you said.
The problem is that I don't know if the SWED RDF Harvaster set the
"Accept" option to "application/rdf+xml". If it doesn't the problem
is not resolved beacuse a can't simulate the URL of an RDF file with
the sparql url service you suggested to me.

Eventually , waiting for a proper servlet bundled with Anzo, I would
try to create my own servlet bundle for Anzo.

Where can I find some documentation/tutorial or guide on how to add
service (servlet in my case) as a bundle in Anzo in the osgi
framework? (I'm not so skilled on osgi)

Thanx again for the useful support,
Busa.

On Jun 15, 6:42 pm, Jordi Albornoz Mulligan
<jo...@cambridgesemantics.com> wrote:
> Matteo wrote:
> > Hi.
> > I tried you solution but nothing back from the sparql servlet.
>
> > In my case I have imported an RDF namedhttp://imolinfo.it/undefined
>
> > and I made this request:
> >http://localhost:8282/sparql/?query=CONSTRUCT%20%7B%20%3Fs%20%3Fp%20%...
Reply all
Reply to author
Forward
0 new messages