Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Creating Webservices in SMILA from OSGi services using JAX-WS
SMILA includes a simple tool now that make it possible to publish OSGi services which are implemented as JAX-WS webservices so that they can be accessed externally using HTTP/SOAP. The short story is:
- activate bundle org.eclipse.smila.webservice
- register you JAX-WS class as an OSGI service and add a property org.eclipse.smila.ws that specifies the service name in the HTTP-URL. You can use either Declarative Services to do this or do the registration manually in code.
- access the webservice under http://<your-hostname>:8081/<service-name>?wsdl
Configuration of the Webservice Publisher
The Webservice Publisher in bundle org.eclipse.smila.webservice is basically a Service Tracker that looks for all services with a property org.eclipse.smila.ws and publishs them using the standard JAX-WS integration in Java 6 JDKs. The only thing that can be configured currently is how the webservice's URL is constructed. This is done in a simple configuration property file named webservice.properties that is located in configuration/org.eclipse.smila.webservice. If no such file exists, the default settings are used. Also, all properties in the file are optional.
- The host name part of the webservice URL. If not set, the publisher tries to determine the hostname using java.net.InetAddress, if this does not work, localhost is used. Note that if you need to access your webservice using http://localhost:..., you must specify webservice.hostname=localhost here. Else you must use the correct hostname to connect to the webservice.
- The TCP/IP port of the webservice server. Default is 8081, as 8080 is already used by the HTTP server in SMILA.
- A common root part for the webservice URLs. Default is empty.
The webservice URL is constructed like this: http://<webservice.hostname>:<webservice.port>/<webservice.webroot>/<service-name>
A simple HelloWorld service is contained in bundle org.eclipse.smila.webservice.test. It also includes WSDL/XSD files generated from the service class, client stubs generated from the WSDL file and the batch files to generate this stuff (though the WSDL and service client class have been manipulated a bit afterwards). The service is started using OSGi Declarative Services, so OSGI-INF/component.xml is an example of how to define the service property the publisher looks for in DS. If you copy the publisher configuration in this bundle to your configuration area and activate the bundle (and the publisher bundle, of course), the service should be accessible under http://localhost:8081/smila-ws/helloworld.
The test bundle org.eclipse.smila.processing.bpel.test also contains a BPEL file helloworldpipeline.bpel that invokes this service with an attribute value from the processed record and writes the result back to the same attribute in this record.
These are only very simple examples, and admittedly we did not do more complex tests yet. If something in JAX-WS does not work with the SMILA webservice publisher please let us know. Also any other suggestions for improvement are highly appreciated. Thank you very much.