Previous topic  Top  Next topic  Print this Topic
 

Extensions Directory to Deploy Web Services

 

To add a Web service to OntoBroker, you simply implement the normal JAX-WS webservice class which implements the marker interface OntoBrokerService and publishes it as an OntoBrokerService to OSGI.

package com.ontoprise.ontobroker.webservice;

 

/**

* Marker interface for web services deployed together with OntoBroker

*/

@ExcludeAll

public interface OntoBrokerService {

}

The skeleton of your Web service class will look like this:

package com.acme.mywebservice

 

@javax.jws.WebService(endpointInterface ="com.acme.mywebservice.MyItf")

public class MyService implements MyItf, OntoBrokerService {

  private OntologyManager _ontologyManager;

 

  protected void bindOntoBrokerServiceManager(OntoBrokerServiceManager manager) {

      _ontologyManager = manager.getOntologyManager();

  }

 

  //  web service operations are added here

}

Normally a Web service deployed in OntoBroker needs access to the ontologies or the reasoner. For this purpose, your webservice class should reference the OntoBrokerServiceManager service and remember the OntologyManager on the bind operation. In addition you need to specify the relative address for publishing the Web service endpoint.

<?xml version="1.0" encoding="UTF-8"?>

<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.acme.mywebservice">

  <implementation class="com.acme.mywebservice.MySvc"/>

  <reference cardinality="1..1" interface="com.ontoprise.ontobroker.webservice.OntoBrokerServiceManager" name="OntoBrokerServiceManager" policy="static" bind="bindOntoBrokerServiceManager" />

    <provide interface="com.ontoprise.ontobroker.webservice.OntoBrokerService"/>

  </service>

  <property name="address" type="String" value="/myservice"/>

</scr:component>

The rest is similar to the above description for the built-in bundle.

Dynamic Web Services

Dynamic Web services are only generated automatically from OntoStudio or with the OntoBroker command generateDynamicSvc.