-
Notifications
You must be signed in to change notification settings - Fork 35
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 and they offer some training sessions, which have some very straightforward and concise introduction materials.
Let's walk through a typical interaction with a SADI service.
Step 1: Find out that http://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 http://sadiframework.org/examples/hello > service-interface-definition.ttl
Step 3: See what owl:Class it accepts (NamedIndividual):
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix mygrid: <http://www.mygrid.org.uk/mygrid-moby-service#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
<http://sadiframework.org/examples/hello>
mygrid:hasOperation [
mygrid:inputParameter [
mygrid:objectType <http://sadiframework.org/examples/hello.owl#NamedIndividual> ;
a mygrid:parameter
] ;
Step 4: Grab the description of NamedIndividual:
rapper -g -o turtle http://sadiframework.org/examples/hello.owl#NamedIndividual > hello.owl
and (Step 5) find out that NamedIndividual needs at least one foaf:name:
<http://sadiframework.org/examples/hello.owl#NamedIndividual>
a owl:Class ;
owl:equivalentClass [
a owl:Restriction ;
owl:minCardinality "1"^^<http://www.w3.org/2001/XMLSchema#int> ;
owl:onProperty <http://xmlns.com/foaf/0.1/name>
] .
Step 6: Gin up some input to feed the service:
bash-3.2$ cat input.ttl
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://tw.rpi.edu/instances/TimLebo>
a <http://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 http://sadiframework.org/examples/hello
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:hello="http://sadiframework.org/examples/hello.owl#">
<hello:GreetedIndividual rdf:about="http://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: <http://sadiframework.org/examples/hello.owl#> .
<http://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.
See the page on DataFAQs wiki for how to write your first SADI service in python.