There are many different methods for computing alignments. However, they always need at least two ontologies as input and provide an alignment as output. So, a minimal interface for providing an alignment should contain:
This method takes as parameters the URIs of the two ontologies to be matched and returns a String representing the alignment. In order to make available such an interface as an operation within a web service, we define a minimal web service interface, as presented below.
Different ways for creating web services can be used. Here we propose to follow the Java API for XML Web Services (JAX-WS). Following this approach, a service endpoint is a Java interface or class that specifies the methods that a client can invoke on the service. The development of JAX-WS web services is based on a set of annotations. The @WebService annotation defines the class as a web service endpoint while @WebMethod defines the operations of this web service. We can determine the encoding style for messages send to and from the Web Service, through the annotation @SOAPBinding.
Our minimal web service interface is defined as follow (AlignmentWS.java):
This interface defines a service endpoint, AlignmentWS and its operation, align, which takes as parameters the URIs of the two ontologies to be aligned and returns a String representing the alignment.
Extending the web service interface requires the definition of the corresponding interface by adding the endpointInterface element to the @WebService annotation in the implementation class (AlignmentWSImpl.java):
The method align must implement the matching process. The easiest way to do this is to implement the Alignment API (see details in how to extend the Alignment API with a new matcher). Basically, you need to implement the AlignmentProcess interface (method align) and extend the URIAlignment class (MyAlignment.java):
The complete example, following how to extend the Alignment API with a new matcher, can be found at MyAlignmentComplete.java.
Then, it is simple to expose MyAlignment as a web service (MyAlignmentWS.java):
Note that we have added a loop for removing the cells in the URIAlignment object (lines before the method init(source,target)). This is due the fact that the method align will be called several times in a web service cycle life (for each test). If we do not remove the cells computed in a previous call, the previous cells will be included in the current result.
Nothing more is needed.
You can download SBWriter.java.
In order to be available for external access, the web service must be published at an endpoint, at which point it starts accepting incoming requests. This could be done by creating a WAR file to be deployed in a tomcat server, or by creating a publisher. In the second case, the publisher can use the method publish to publish its address to the Endpoint (AlignmentWSPublisher.java):
The endpoint has to be started on a public available machine (a machine that is accessible from the internet). In the example above we specified the IP 126.96.36.199 as part of the address, because it is the IP of the machine that we used for testing the example. If you make your matcher available as a webservice based on this example, you have to additionally take into account the following:
The service can be accessed at via the URL http://188.8.131.52:8080/matcherWS and its WSDL - describing its methods - can be found at http://184.108.40.206:8080/matcherWS?wsdl.
To use the seals infrastructure you have to specify the class including its package specification (e.g. example.ws.matcher.AlignmentWSImpl or example.ws.matcher.MyAlignmentWS) and you have to specify the URL of the service endpoint (e.g. http://220.127.116.11:8080/matcherWS or http://18.104.22.168:8080/matcherWS?wsdl).
You might be interested to deploy the matcher webservice at a stable endpoint on a Tomcat application server. We have prepared a minimal matcher as described in the tutorial and some additional files (xml files for deployment, libraries, ant-file) that are required to deploy the service on a Tomcat server. The whole bundle is available here for download!
Unzip the file and open the readme.txt file. It explains how to generate, deploy and test the webservice. It is required that you have ant installed to use it.
More info: https://moex.gitlabpages.inria.fr/alignapi/tutorial/