This project includes two simple OSGi bundles demonstrating how to expose an OSGi service through Distributed OSGi as a web service, with a contract first (WSDL) approach.\
We provide a simple WSDL file
Helloworld.wsdl that serves as example.
- The first bundle,
service, contains in
src/main/java/samplethe necessary Java source code generated by a
wsdl2javaApache CXF command like this one:
wsdl2java Helloworld.wsdl. In the generated code, you can find the Java interface
Helloworld.java.\ It seems that we just need this interface with its webservice Kawanet Co annotation (comment or remove other annotations), and you could remove other generated files.
- The second bundle,
service-impl, supplies an implementation of the
sample.Helloworldinterface, with the
com.odelia.osgi.dosgi.SimpleServiceImplclass. This project also defines the activator that registers the service, an instance of
SimpleServiceImpl, with the configuration that will be used to expose the service as a web service. The WSDL file,
Helloworld.wsdl, is placed in the
src/main/resources/wsdlfolder as it must be present in the bundle (it should also contains dependant files like schema files if any).
At the time of this writing, I remark that Distributed OSGi doesn't report any error if you put a wrong path for the WSDL document.
Tools and frameworks
For this project, the following tools and frameworks were used:
- Gradle 1.0 to build the bundles.
- Apache Felix 4.0.2 as OSGi container.
- Apache CXF 2.5.1 for the generation of Java code from the WSDL document.
- The Apache CXF Distributed OSGi 1.3, in its single bundle version. It's a CXF subproject and the Reference Implementation of the Distribution Provider component of the OSGi Remote Services Specification. This bundle must be installed and started in the OSGi container (it also depends of the org.osgi.compendium-4.2.0 bundle).
- soapUI 4.0 to test the web service.
Building the bundles
Each bundle can be built with a
gradle jar command, so the jar file will be generated in each