Maryland 大學計算機系的Evren Sirin 開發。OWL-S API的類庫主要建立在Axis, Jena 以及Pellet上。
Apache Axis 是Apache Web Service項目中的子項目,其最初起源于IBM的"SOAP4J",應該屬于最早的一批用于構造基于SOAP應用的Framework。它支持WSDL1.1,可自動由Java Object生成WSDL。
Jena主要用來處理RDF,主要使用Jena的推理能力從本體推斷模型知識。
Pellet是一個開源的基于JAVA的OWL推理機。
包中還自帶兩個jar包形式的java類庫,owl-s.jar和upnp.jar。
該OWL-S API的主要功能如下:
讀/寫服務描述:
OWL-S
API中有兩個重要的接口:OWLOntology和OWLKnowledgeBase。OWLOntology代表了存儲在單個文件中的信息,而
OWLKnowledgeBase是許多Ontology的集合。RDF數據可以加載到OWLOntology上,只有OWLOntology對象才能組
合起來。OWLKnowledgeBase中只有一個Ontology是用來存儲數據的(例如執行之后,新的實例會被加到這個OWLOntology上。
函
數OWLKnowledgeBase.read(URI)從給定的Ontology讀取信息,并產生OWLOntology。函數
OWLOntology.getService()用來獲取ontology中的服務實例。如果有許多服務,則用
OWLOntology.getServices()獲取。然后,函數OWLKnowledgeBase.readService(URI)以及
OWLKnowledgeBase.readServices(URI)將會讀取服務。如果函數調用發生錯誤將會產生null輸出。
函數OWLOntology.write(Writer)可以使包含服務的ontology組合起來。
這是一個例子:
URI uri = new URI("http://www.mindswap.org/2004/owl-s/0.9/ZipCodeFinder.owl");
// create a KB
OWLKnowledgeBase kb = OWLFactory.createKB();
// create a generic reader and a 1.0 writer
OWLOntology ont = kb.read(uri);
// get the service
Service service = ont.getService();
// write the output to console (a file stream can also be used here)
ont.write(System.out);
將舊服務描述轉換為新描述。
驗證
緩存Ontology
執行服務:
執
行服務意味著執行它的process。Process應該有有效的grounding說明,以便有效的調用服務。WSDL和UPnP的grounding
由API支持,函數ProcessExecutionEngine.execute(Process,
ValueMap)可以執行一個process,ValueMap表示輸入的值,這個函數返回輸出值。
舉例如下:
ProcessExecutionEngine exec = OWLSFactory.createExecutionEngine();
// load the service description
Service service = kb.readService("http://www.mindswap.org/2004/owl-s/1.0/Dictionary.owl");
// get the process of the service
Process process = service.getProcess();
// create an empty value map
ValueMap values = new ValueMap();
// set the value of input parameter
values.setDataValue(process.getInput("InputString"), "computer");
// execute the process with the given input bindings
values = exec.execute(process, values);
// get the output value as a string
String outValue = values.getStringValue(process.getOutput());
// display the result
System.out.println("Output = " + outValue);
執行跟蹤功能:
當執行復雜的服務時,知道執行的過程是很有用的,ProcessExecutionListener就是為這一目的設計的。
ProcessExecutionEngine.addExecutionListener(ProcessExecutionListener)就可以
為執行器添加這么一個監聽器。
生成復合過程
可以用程序產生服務的descriptions, profile或者processes描述。OWLOntology接口實現了這個功能。
*
* Create a new Sequence from the processes of the given services and put them in a new
* Service.
*
* @param services List of Services
* @param baseURI The base URI for the generated service
* @return The Service which is a Sequence of the given services
*/
Service createSequenceService(List services, String baseURI) {
// create an empty ontology
OWLOntology ont = OWLFactory.createOntology();
// create a new service
Service service = ont.createService(URI.create(baseURI + "Service"));
// create a new composite process
CompositeProcess process = ont.createCompositeProcess(URI.create(baseURI + "Process"));
// create a new sequence construct
Sequence sequence = ont.createSequence();
// put the sequence into composite process
compositeProcess.setComposedOf(sequence);
for(int i = 0; i < services.size(); i++) {
// get the service from the list
Service s = (Service) services.get(i);
// get the process fron the service
Process p = s.getProcess();
// create a perform construct
Perform perform = ont.createPreform();
perform.setProcess(p);
// put the process into the sequence
sequence.addComponent(p);
// create data flow if necessary

}
// create profile

// create grounding
return service;
}
支持功能。