CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 36
SADI Semantic Web Services framework
Semantic Automated Discovery and Integration (SADI) is the coolest way to do web services. It requires so little, and naturally reuses the semantic web to communicate what each service does by using OWL semantics for its inputs and outputs. If OWL is too heavyweight, then you can also just use RDFS. Their source code is on google code, they have sadi-discuss and sadi-dev email lists, and they offer some training sessions, which have some very straightforward and concise introduction materials.
(protege's SADI plugin or curl to POST an RDF file to it)
Let's walk through a typical interaction with a SADI service.
Step 1: Find out that https://sadiframework.org/examples/hello is a SADI service.
Step 2: Get a Turtle description of the service from the service itself (using the RDF pocketknife rapper):
rapper -g -o turtle https://sadiframework.org/examples/hello > service-interface-definition.ttl
Step 3: See what owl:Class it accepts (NamedIndividual
):
@prefix rdf: <https://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix mygrid: <https://www.mygrid.org.uk/mygrid-moby-service#> .
@prefix rdfs: <https://www.w3.org/2000/01/rdf-schema#> .
<https://sadiframework.org/examples/hello>
mygrid:hasOperation [
mygrid:inputParameter [
mygrid:objectType <https://sadiframework.org/examples/hello.owl#NamedIndividual> ;
a mygrid:parameter
] ;
Step 4: Grab the description of NamedIndividual
:
rapper -g -o turtle https://sadiframework.org/examples/hello.owl#NamedIndividual > hello.owl
and (Step 5) find out that NamedIndividual
needs at least one foaf:name:
<https://sadiframework.org/examples/hello.owl#NamedIndividual>
a owl:Class ;
owl:equivalentClass [
a owl:Restriction ;
owl:minCardinality "1"^^<https://www.w3.org/2001/XMLSchema#int> ;
owl:onProperty <https://xmlns.com/foaf/0.1/name>
] .
Step 6: Gin up some input to feed the service:
bash-3.2$ cat input.ttl
@prefix foaf: <https://xmlns.com/foaf/0.1/> .
<https://tw.rpi.edu/instances/TimLebo>
a <https://sadiframework.org/examples/hello.owl#NamedIndividual>;
foaf:name "Tim";
.
Step 7: Send it off with an HTTP POST to get your greeting (to me):
bash-3.2$ curl -H "Content-type: text/rdf+n3" -d @input.ttl https://sadiframework.org/examples/hello
<rdf:RDF
xmlns:rdf="https://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:hello="https://sadiframework.org/examples/hello.owl#">
<hello:GreetedIndividual rdf:about="https://tw.rpi.edu/instances/TimLebo">
<hello:greeting>Hello, Tim!</hello:greeting>
</hello:GreetedIndividual>
</rdf:RDF>
Add -H "Accept: text/rdf+n3"
to get Turtle instead of RDF/XML:
@prefix hello: <https://sadiframework.org/examples/hello.owl#> .
<https://tw.rpi.edu/instances/TimLebo>
a hello:GreetedIndividual ;
hello:greeting "Hello, Tim!" .
There is a SADI plugin for Protege that lets you invoke a SADI service using instances in a currently loaded ontology.
While browsing the SADI service listing, I noticed https://unbsj.biordf.net/util-sadi-serv/pdf2ascii.
Sounds useful for a variety of applications. Let's see if we can use SADI to get some ascii from a PDF.
$ rapper -q -g -o turtle https://unbsj.biordf.net/util-sadi-serv/pdf2ascii
@prefix rdf: <https://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix j.0: <https://www.mygrid.org.uk/mygrid-moby-service#> .
<https://unbsj.biordf.net/util-sadi-serv/pdf2ascii>
j.0:hasOperation <https://unbsj.biordf.net/util-sadi-serv/pdf2ascii#operation> ;
j.0:hasServiceDescriptionText "Extracts ASCII contents from a PDF file" ;
j.0:hasServiceNameText "pdf2ascii"^^<https://www.w3.org/2001/XMLSchema#string> ;
a <https://www.mygrid.org.uk/mygrid-moby-service#serviceDescription> .
<https://unbsj.biordf.net/util-sadi-serv/pdf2ascii#input>
j.0:objectType <https://unbsj.biordf.net/util-sadi-services/util-sadi-services-ontology.owl#pdf2ascii_Input> ;
a <https://www.mygrid.org.uk/mygrid-moby-service#parameter> .
<https://unbsj.biordf.net/util-sadi-serv/pdf2ascii#operation>
j.0:inputParameter <https://unbsj.biordf.net/util-sadi-serv/pdf2ascii#input> ;
j.0:outputParameter <https://unbsj.biordf.net/util-sadi-serv/pdf2ascii#output> ;
a <https://www.mygrid.org.uk/mygrid-moby-service#operation> .
<https://unbsj.biordf.net/util-sadi-serv/pdf2ascii#output>
j.0:objectType <https://unbsj.biordf.net/util-sadi-services/util-sadi-services-ontology.owl#pdf2ascii_Output> ;
a <https://www.mygrid.org.uk/mygrid-moby-service#parameter> .
OK, it wants an instance of https://unbsj.biordf.net/util-sadi-services/util-sadi-services-ontology.owl#pdf2ascii_Input.
rapper -g -o turtle https://unbsj.biordf.net/util-sadi-services/util-sadi-services-ontology.owl#pdf2ascii_Input
shows:
@prefix rss: <https://purl.org/rss/1.0/> .
@prefix bibo: <https://purl.org/ontology/bibo/> .
@prefix dc: <https://purl.org/dc/elements/1.1/> .
:pdf2ascii_Input
a owl:Class ;
owl:equivalentClass [
a owl:Class ;
owl:unionOf (bibo:Document
[
a owl:Class ;
owl:intersectionOf ([
a owl:Restriction ;
owl:onProperty rss:link ;
owl:someValuesFrom xsd:anyURI
]
[
a owl:Restriction ;
owl:hasValue "application/pdf" ;
owl:onProperty dc:format
]
)
]
)
] .
So, gin up the following RDF:
@prefix rss: <https://purl.org/rss/1.0/> .
@prefix bibo: <https://purl.org/ontology/bibo/> .
@prefix dc: <https://purl.org/dc/elements/1.1/> .
<https://www.springerlink.com/content/v562h13xp5n8u880/fulltext.pdf#>
a bibo:Document;
rss:link <https://www.springerlink.com/content/v562h13xp5n8u880/fulltext.pdf>;
dc:format "application/pdf";
.
Dumb it down to RDF/XML with rapper -g -o rdfxml mydoc.ttl > mydoc.rdf
and send it off:
curl -d @mydoc.rdf https://unbsj.biordf.net/util-sadi-serv/pdf2ascii
and get the very disappointing response:
<rdf:RDF
xmlns:rdf="https://www.w3.org/1999/02/22-rdf-syntax-ns#" >
</rdf:RDF>
A bit anti-climatic. And, the service doesn't provide contact information, so we're stuck. Bummer.
See the page on DataFAQs wiki for how to write your first SADI service in python.