-
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 -i rdfxml -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 -i rdfxml -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!" .
Jim McCusker created a python API that can be used to create a SADI service. This adds a third language to the two that already exist (Java and Perl).
Installing Jim's python API:
- sadi.googlecode.com
- http://sadi.googlecode.com/files/sadi-0.1.1-py2.6.egg
sudo easy_install http://sadi.googlecode.com/files/sadi-0.1.1-py2.6.egg
Some python += rdf references:
- http://code.google.com/p/rdflib/wiki/Learning
- http://diveintopython.org/
- http://en.wikipedia.org/wiki/RDFLib
protege's SADI plugin or curl to POST an RDF file to it.
To find out what the service does, request the service directly:
curl http://localhost:9090/HomologeneClusterConsistency > HomologeneClusterConsistency.rdf
It will return an RDF description that cites the owl:Class of instances it inputs, and another for the instances it outputs:
@base <http://localhost:9090/HomologeneClusterConsistency> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ns1: <http://www.mygrid.org.uk/mygrid-moby-service#> .
@prefix ns2: <http://protege.stanford.edu/plugins/owl/dc/protege-dc.owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
<>
ns1:hasOperation <#operation> ;
ns1:hasServiceDescriptionText "Compute the correlation of gene membership for a particular Homologene" ;
ns1:hasServiceNameText "Homologene Cluster Consistency Service" ;
ns1:providedBy <http://tw.rpi.edu> ;
a ns1:serviceDescription ;
rdfs:comment "Homologenes" ;
rdfs:label "Homologene Cluster Consistency" .
<#input>
ns1:objectType <http://logd.tw.rpi.edu/source/ncbi-nlm-nih-gov/dataset/homologene/vocab/HomologyCluster> ;
a ns1:parameter .
<#operation>
ns1:inputParameter <#input> ;
ns1:outputParameter <#output> ;
a ns1:operation .
<#output>
ns1:objectType
<http://logd.tw.rpi.edu/source/twc-rpi-edu/dataset/homologene-consistency/vocab/CorrelatedHomologyCluster> ;
a ns1:parameter .
<http://tw.rpi.edu>
ns2:creator "l..@rpi.edu" ;
ns1:authoritative true ;
a ns1:organisation .
Jim started a collection of services for LOBD in its google code svn.
So stitch together a post-me.ttl.rdf:
@prefix homologene: <http://logd.tw.rpi.edu/source/ncbi-nlm-nih-gov/dataset/homologene/version/build65/> .
@prefix homologene_vocab: <http://logd.tw.rpi.edu/source/ncbi-nlm-nih-gov/dataset/homologene/vocab/> .
homologene:homologyCluster_3 a homologene_vocab:HomologyCluster .
and HTTP POST it to the service:
curl -d @post-me.ttl.rdf http://localhost:9090/HomologeneClusterConsistency
Listing of SADI services with a SPARQL endpoint: http://sadiframework.org/registry/ (NOT easy to find from their home page).
http://localhost:9090/HomologeneClusterConsistency
- wrap prefix.cc?
- expose PMM