CS560 Lab 4-B: Semantic Web Services

economickiteInternet και Εφαρμογές Web

21 Οκτ 2013 (πριν από 3 χρόνια και 7 μήνες)

57 εμφανίσεις

CS560 Lab 4
-
B
:
Semantic Web Services

Due date:
3/10 (W
), Midnight

Post the report to your website


1. Background


Semantic Web services refers to set of Semantic Web based representation models
wrapped over plain Web services model

(
http://www.w3.org/2002/ws/
)
. The idea is to
make Web services self
-
describing by attaching explicit Semantics to the
Inputs/Outputs/Preconditions/Postconditions

(IOPE)

of a service instance as well as
representations for the flow and a
tomic tasks rendered by the service. Some common
examples of Semantic Web services are : Flight/Hotel Reservation Service
s, Online
Book(or any commodity) Buying Service, domain specific services (EAI, Medical
Services etc).


The applications of Semantic W
eb services are to allow automated agent based Service
Discovery, Composition and Execution thereby providing dynamic B2B and B2C
interactions over Web.



OWL
-
S proposes a set of OWL based standards for putting a Semantic wrapper over
traditional Web serv
ices so agents can dynamically discover and invoke Web services.
OWL
-
S model is currently under development and a related W3C coalition Semantic
Web services Interest group has

been formed

(
http://www.w3.org
/2002/ws/swsig/
)


To get more information and idea of OWL
-
S, refer to
http://www.daml.org/services/

Following diagram succinctly describes the overall OWL
-
S philosophy.




Fig : OWL
-
S Model


2.
Querying Sem
antic Web
S
ervices


After thoroughly understanding the basic OWL
-
S model, Download Congo.com or
Bravo Air examples through
http://www.daml.org/services/owl
-
s/1.0/examples.html


Develop R
DQL queries to extract the important features from the OWL
-
S files


BravoAirService.owl


SELECT ?Service ?Profile ?Process ?Grounding

WHERE

(?Service <http://www.daml.org/services/owl
-
s/1.0/Service.owl#presents> ?Profile)

(?Service <http://www.daml.or
g/services/owl
-
s/1.0/Service.owl#describedBy> ?Process)

(?Service <http://www.daml.org/services/owl
-
s/1.0/Service.owl#supports> ?Grounding)


Service

= http://www.daml.org/services/owl
-
s/1.0/BravoAirService.owl#BravoAir_ReservationAgent


Profile

= http:
//www.daml.org/services/owl
-
s/1.0/BravoAirProfile.owl#Profile_BravoAir_ReservationAgent


Process

=http://www.daml.org/services/owl
-
s/1.0/BravoAirProcess.owl#BravoAir_ReservationAgent_ProcessModel


Grounding

=http://www.daml.org/services/owl
-
s/1.0/BravoAi
rGrounding.owl#Grounding_BravoAir_ReservationAgent


BravoAir
Profile
.owl


SELECT ?Input WHERE (<"+Profile+"> <http://www.daml.org/services/owl
-
s/1.0/Profile.owl#hasInput> ?Input)


//Profile is a variable obtained from Service.owl


Input :http://www.daml.o
rg/services/owl
-
s/1.0/BravoAirProcess.owl#InboundDate_In

Input :http://www.daml.org/services/owl
-
s/1.0/BravoAirProcess.owl#PreferredFlightItinerary_In

Input :http://www.daml.org/services/owl
-
s/1.0/BravoAirProcess.owl#RoundTrip_In

Input :http://www.daml.org
/services/owl
-
s/1.0/BravoAirProcess.owl#Confirm_In

Input :http://www.daml.org/services/owl
-
s/1.0/BravoAirProcess.owl#DepartureAirport_In

Input :http://www.daml.org/services/owl
-
s/1.0/BravoAirProcess.owl#ArrivalAirport_In

Input :http://www.daml.org/services
/owl
-
s/1.0/BravoAirProcess.owl#Password_In

Input :http://www.daml.org/services/owl
-
s/1.0/BravoAirProcess.owl#AcctName_In

Input :http://www.daml.org/services/owl
-
s/1.0/BravoAirProcess.owl#OutboundDate_In

Input :http://www.daml.org/services/owl
-
s/1.0/BravoAi
rProcess.owl#ReservationID_In



SELECT ?Out
put WHERE (<"+Profile+"> <http://www.daml.org/services/owl
-
s/1.0/P
rofile.owl#hasOutput> ?Output
)


Output :http://www.daml.org/services/owl
-
s/1.0/BravoAirProcess.owl#PreferredFlightItinerary_Out

Output :http://ww
w.daml.org/services/owl
-
s/1.0/BravoAirProcess.owl#AcctName_Out

Output :http://www.daml.org/services/owl
-
s/1.0/BravoAirProcess.owl#AvailableFlightItineraryList_Out

Output :http://www.daml.org/services/owl
-
s/1.0/BravoAirProcess.owl#ReservationID_Out






3.
Exercise:


Using Jena RDQL
extract important features from the
BravoAirProcess.owl

(Composite Services) and
BravoAirGrounding.owl


[Be Smart

:
To

understand how to extract
a
given feature, print a
ll the triples for the
corresponding OWL file using generic
RDQL query (?x, ?y, ?z)

then manually Ctrl+F

for the required

feature/property in the output dump

]


1)

Extract Composite Processes in the
BravoAirProcess.owl

[hint :
?X
<
http://www.w3.org/1999/02/22
-
rdf
-
syntax
-
ns#type
>

<
http://www.daml.org/services/owl
-
s/1
.0/Process.owl#CompositeProcess
>
]


2)

Extract Atomic Processes for a Given Composite Process

[hint :

(
<
http://xyz#CompProc
>

<
http://www.daml.org/services/owl
-
s/1.0/Process.owl#composedOf
>

?Anon1
),

(
?Anon1
<
http://www.daml.org/services/owl
-
s/1.0/Process.owl#c
omponents
>

?Anon2
)


What you get in ?Anon2 is a RDF Sequence (
http://www.w3.org/TR/2004/REC
-
rdf
-
syntax
-
grammar
-
20040210/#section
-
Syntax
-
parsetype
-
Collection
) using
which you iterate through different Atomic services (#Login,
#ConfirmReservation)



<
process:CompositeProcess rdf:ID
="
BookFlight
">

<
process:composedOf
>

<
process:Sequence
>


<
process:components rdf:parseType
="
Collection
">



<
process:AtomicProcess

rdf:about
="
#Login
" />




<
process:AtomicProcess

rdf:about
="
#ConfirmReservation
" />




</
process:components
>


</
process:Sequence
>



</
process:composedOf
>


</
proce
ss:CompositeProcess
>


Appendix 1
gives

the code to iterate
through the atomic processes
for a given composite process
using ?Anon2]


3)

For each of the Atomic Services extracted from Question 2 extract
corresponding
WsdlAtomicProcessGrounding

concepts

e.g.


I
n BravoAirGrounding.owl, ConfirmReservation has grounding to
WsdlGrounding_ConfirmReservation


Subject


:http://www.daml.org/services/owl
-
s/1.0/BravoAirGrounding.owl#WsdlGrounding_ConfirmReservation


Predicate :http://www.daml.org/services/owl
-
s/1.0/Groun
ding.owl#owlsProcess


Object :http://www.daml.org/services/owl
-
s/1.0/BravoAirProcess.owl#
ConfirmReservation


4)

As shown before
: From the BravoProfile.owl, extract all Inputs and find
corresponding Web service Input port types.

[hint :


(
?Anon1 <http://www.da
ml.org/services/owl
-
s/1.0/Grounding.owl#owlsParameter> XYZ
process.owl#Input),


(?Anon1
<http://www.daml.org/services/owl
-
s/1.0/Grounding.owl#wsdlMessagePart> ?Anon2),


(?Anon2 <
http://www.w3.org/1999/02/22
-
rdf
-
syntax
-
ns#value
>
?WSDLINPUT)

































Developing Semantic Web services


Consider an Example of a
PatientNutritionService

whic
h has algorithm to determine the
Meal Plan for a patient,

given patient
’s context parameters such as Calorie Level,
Diagnosis, Food Items available in th
e hospital. The precondition for the Service is that
current time should be within the range of Lunc
hTime and the post condition
of the
service would be CommitLunch (i.e.
Lunc
h was delivered)


<PatientNutritionService>

<Input>


http://www.KingdomHospital.o
rg/PatientOntology.owl#
PatientMRNumber


http://www.KingdomHospital.org/FoodOntology.owl#
CalorieLevel


http://www.KingdomHospital.org/PatientOntology.owl#
Diagnosis


http://www.KingdomHospital.org/
HospitalInventory.owl#
FoodItems

</Input>

<Output>


http://www
.KingdomHospital.org/FoodOntology.owl#
MealPlan

</Output>

<PreCondition>


http://www.KingdomHospital.org/ScheduleOntology.owl#
LunchTime

</PreCondition>

<PostCondition>


http://www.KingdomHospital.org/EventOntology.owl#
CommitLunch

</PostCondition>


Exercise
:

Develop a OWL
-
S based representation for the PatientNutritionService with
the above parameters.


Develop

i). PatientNutritionService.owl

ii). PatientNutritionProfile.owl

iii). PatientNutritionProcess.owl

[Conceive and add Composite processes for addi
tional points !]

iv). PatientNutritionGrounding.owl

[Assume appropriate WSDL location
s
]













Appendix I


Although Jena RDF provides a Seq class to iterate through sequences but if you notice in
current OWL
-
S Process Ontology



<
rdf:Property rdf:ID
=
"
components
">



<
rdfs:comment
>
The components propery of a control construct holds a
specific arrangement of subprocesses or control constructs. The range is
declared at each subclass of ControlConstruct.
</
rdfs:comment
>




<
rdfs:domain

rdf:resource
="
#Cont
rolConstruct
" />




</
rdf:Property
>


The
rdfs:range

of
components property has been left unspecified, hence the Jena parser
cannot determine that the Object is a rdf:Sequence or rdf:Bag or other resource !


Here is small utility class that would help in it
erating through the components list


class SWSSeq {



Resource anon; //The first resource of Sequence




public SWSSeq(Resource anon){ //Initialize the class with the type cast of
(Resource)res.getObject("?Anon2")


this.anon = anon;


}



public boo
lean hasNext(){




if(anon.toString().equals("http://www.w3.org/1999/02/22
-
rdf
-
syntax
-
ns#nil"))


return false;


else


return true;



}//end of hasNext



public Object next(){


StmtIterator aiter = anon.listProperties();



while(aiter.hasNext()){


Statement stmt = aiter.nextStatement();


String pred = stmt.getPredicate().toString();


if(pred.equals("http://www.w3.org/1999/02/22
-
rdf
-
syntax
-
ns#first")){
//Fetch firs
t object


moveAhead(); //Iterate to next object


return stmt.getObject();


}


}


return null;


}



private void moveAhead(){


StmtIterator aiter = anon.listPropertie
s();


while(aiter.hasNext()){


Statement stmt = aiter.nextStatement();


String pred = stmt.getPredicate().toString();


if(pred.equals("http://www.w3.org/1999/02/22
-
rdf
-
syntax
-
ns#rest")){



RDFNode objNode = stmt.getObject();


if(objNode instanceof Resource)


{


anon = (Resource)objNode;


return;



}


}


} }

}// end of SWSSeq