从有效的OWLS文档中获取空的服务列表

时间:2014-05-18 19:09:45

标签: web-services semantic-web owl

我正在与一个废弃的java库(带有一个maven存储库)进行斗争,以便与名为OWLSowls-api一起使用。我试图从OWLS文档中获取服务列表:

OWLKnowledgeBase kb = OWLFactory.createKB();        
OWLIndividualList<Service> services = kb.readAllServices("http://127.0.0.1/services/1.1/BookPrice.owls");
        System.out.println(services.toString());

我不断获得一个空的services列表,为什么

<?xml version="1.0" encoding="WINDOWS-1252"?>
<rdf:RDF  xmlns:owl       = "http://www.w3.org/2002/07/owl#"
xmlns:rdfs      = "http://www.w3.org/2000/01/rdf-schema#"
xmlns:rdf       = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:service   = "http://www.daml.org/services/owl-s/1.1/Service.owl#"
xmlns:process   = "http://www.daml.org/services/owl-s/1.1/Process.owl#"
xmlns:profile    = "http://www.daml.org/services/owl-s/1.1/Profile.owl#"
xmlns:grounding = "http://www.daml.org/services/owl-s/1.1/Grounding.owl#"

xml:base        = "http://127.0.0.1/services/1.1/BookFinder.owls">

<owl:Ontology rdf:about="">
<owl:imports rdf:resource="http://127.0.0.1/ontology/Service.owl" />
<owl:imports rdf:resource="http://127.0.0.1/ontology/Process.owl" />
<owl:imports rdf:resource="http://127.0.0.1/ontology/Profile.owl" />
<owl:imports rdf:resource="http://127.0.0.1/ontology/Grounding.owl" />
<owl:imports rdf:resource="http://127.0.0.1/ontology/books.owl" />
</owl:Ontology>

<service:Service rdf:ID="TITLE_BOOK_SERVICE">
<service:presents rdf:resource="#TITLE_BOOK_PROFILE"/>
<service:describedBy rdf:resource="#TITLE_BOOK_PROCESS"/>
<service:supports rdf:resource="#TITLE_BOOK_GROUNDING"/>
</service:Service>

<profile:Profile rdf:ID="TITLE_BOOK_PROFILE">
<service:isPresentedBy rdf:resource="#TITLE_BOOK_SERVICE"/>
<profile:serviceName xml:lang="en">
BookFinder
</profile:serviceName>
<profile:textDescription xml:lang="en">
This service returns the information of a book whose title best matches the given string.
</profile:textDescription>
<profile:hasInput  rdf:resource="#_TITLE"/>
<profile:hasOutput rdf:resource="#_BOOK"/>

<profile:has_process rdf:resource="TITLE_BOOK_PROCESS" /></profile:Profile>

<!--<process:ProcessModel rdf:ID="TITLE_BOOK_PROCESS_MODEL">
    <service:describes rdf:resource="#TITLE_BOOK_SERVICE"/>
    <process:hasProcess rdf:resource="#TITLE_BOOK_PROCESS"/>
</process:ProcessModel>-->

<process:AtomicProcess rdf:ID="TITLE_BOOK_PROCESS">
<service:describes rdf:resource="#TITLE_BOOK_SERVICE"/>
    <process:hasInput  rdf:resource="#_TITLE"/>
    <process:hasOutput rdf:resource="#_BOOK"/>
</process:AtomicProcess>

<process:Input rdf:ID="_TITLE">
    <process:parameterType rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI">http://127.0.0.1/ontology/books.owl#Title</process:parameterType>
</process:Input>

<process:Output  rdf:ID="_BOOK">
    <process:parameterType rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI">http://127.0.0.1/ontology/books.owl#Book</process:parameterType>
</process:Output >

<grounding:WsdlGrounding rdf:ID="TITLE_BOOK_GROUNDING">
    <service:supportedBy rdf:resource="#TITLE_BOOK_SERVICE"/>
    <grounding:hasAtomicProcessGrounding>
      <grounding:WsdlAtomicProcessGrounding rdf:ID="TITLE_BOOK_AtomicProcessGrounding"/>
    </grounding:hasAtomicProcessGrounding>
</grounding:WsdlGrounding>

<grounding:WsdlAtomicProcessGrounding rdf:about="#TITLE_BOOK_AtomicProcessGrounding">
    <grounding:wsdlDocument rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI"
    >http://127.0.0.1/wsdl/TitleBook.wsdl</grounding:wsdlDocument>
    <grounding:owlsProcess rdf:resource="#TITLE_BOOK_PROCESS"/>
    <grounding:wsdlOperation>
      <grounding:WsdlOperationRef>
        <grounding:operation rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI"
        >http://127.0.0.1/wsdl/TitleBook#get_BOOK</grounding:operation>
        <grounding:portType rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI"
        >http://127.0.0.1/wsdl/TitleBook#TitleBookSoap</grounding:portType>
      </grounding:WsdlOperationRef>
    </grounding:wsdlOperation>
    <grounding:wsdlInputMessage rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI"
    >http://127.0.0.1/wsdl/TitleBook#get_BOOKRequest</grounding:wsdlInputMessage>
    <grounding:wsdlOutputMessage rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI"
    >http://127.0.0.1/wsdl/TitleBook#get_BOOKResponse</grounding:wsdlOutputMessage>
    <grounding:wsdlInput>
      <grounding:WsdlInputMessageMap>
        <grounding:owlsParameter rdf:resource="#_TITLE"/>
        <grounding:wsdlMessagePart rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI"
        >http://127.0.0.1/wsdl/TitleBook#_TITLE</grounding:wsdlMessagePart>
        <grounding:xsltTransformationString>None (XSL)</grounding:xsltTransformationString>
      </grounding:WsdlInputMessageMap>
    </grounding:wsdlInput>
    <grounding:wsdlOutput>
      <grounding:WsdlOutputMessageMap>
        <grounding:owlsParameter rdf:resource="#_BOOK"/>
        <grounding:wsdlMessagePart rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI"
        >http://127.0.0.1/wsdl/TitleBook#_BOOK</grounding:wsdlMessagePart>
        <grounding:xsltTransformationString>None (XSL)</grounding:xsltTransformationString>
      </grounding:WsdlOutputMessageMap>
    </grounding:wsdlOutput>
  </grounding:WsdlAtomicProcessGrounding>

</rdf:RDF>

(*所有静态文件都是使用grizzly java web服务器的well服务器) 有没有替代这个错误的库来处理owls文件?

更新

https://github.com/tarrsalah/owls-example/issues/1

1 个答案:

答案 0 :(得分:1)

这里的RDF数据并不复杂,因此使用SPARQL查询获取您正在寻找的内容并不太难。例如,您可以使用以下查询来获得以下结果:

prefix service: <http://www.daml.org/services/owl-s/1.1/Service.owl#>
select ?service { ?service a service:Service }
----------------------------------------------------------------------
| service                                                            |
======================================================================
| <http://127.0.0.1/services/1.1/BookFinder.owls#TITLE_BOOK_SERVICE> |
----------------------------------------------------------------------

如果您想以编程方式执行此操作,则只需列出该类的实例 http://www.daml.org/services/owl-s/1.1/Service.owl#Service,因此您可以将该类作为OWLClass,并使用getIndividuals来检索其实例集。